Project

Profile

Help

Bug #4605

Spurious error message

Added by Norman Tovey-Walsh 24 days ago. Updated 8 days ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2020-06-19
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
10
Fix Committed on Branch:
Fixed in Maintenance Release:

Description

I have a function that takes an "options" argument. In the general case, it's a map, but as a convenience for users, it accepts a string (or attribute) as well. The most common option is just the language (@xml:lang) so why make users construct a map to pass it?

<xsl:function name="f:syntax-highlight" as="node()*">
  <xsl:param name="source" as="xs:string"/>
  <xsl:param name="options"/>
  <xsl:param name="pyoptions" as="map(xs:string,xs:string)"/>

  <!-- Special case for just the language option -->
  <xsl:variable name="options" as="map(xs:string,xs:string)">
    <xsl:choose>
      <xsl:when test="$options instance of xs:string">
        <xsl:sequence select="map { 'language': $options }"/>
      </xsl:when>
      <xsl:when test="$options instance of attribute()">
        <xsl:sequence select="map { 'language': string($options) }"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:sequence select="$options"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>

Saxon 10.1 warns:

Warning at char 25 in xsl:sequence/@select on line 39 column 71 of highlight.xsl:
  SXWN9000  Evaluation will always throw a dynamic error: A map has no string value

Curiously, I assumed this was some edge case that arose because I was shadowing $options, but I renamed the function parameter to $xoptions and the error persisted.

History

#1 Updated by Norman Tovey-Walsh 24 days ago

Line 39, by the way, is

        <xsl:sequence select="map { 'language': string($options) }"/>

#2 Updated by Michael Kay 15 days ago

  • Status changed from New to In Progress
  • Assignee set to Michael Kay

Sorry for the delay in responding. I haven't succeeded in constructing a repro. I'm not sure where the offending line 39 fits into things, and which $options variable it is referring to.

It might also be necessary to see a complete stylesheet that shows the problem, because it's possible it could relate to function inlining.

#3 Updated by Norman Tovey-Walsh 15 days ago

Line 39 is this one: <xsl:sequence select="map { 'language': string($options) }"/>

The options variable is the xsl;param to the function, I believe. As I said, renaming it to "xoptions" didn't have any effect, so it doesn't seem to be an issue with the shadowing declaration a couple of lines later.

I'll see if I can make a reproducible test case.

#4 Updated by Norman Tovey-Walsh 15 days ago

No. Sorry. I can't now reproduce it. If I see it again, I'll wrap up a test case and send it along. Apologies, I didn't imagine it was going to be difficult to reproduce.

#5 Updated by Michael Kay 12 days ago

  • Status changed from In Progress to Closed

Closing this as unresolved.

#6 Updated by Norman Tovey-Walsh 8 days ago

I have found a reproducible test case. I'll send it in email.

Please register to edit this issue

Also available in: Atom PDF