Bug #4605
closedSpurious error message
0%
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.
Updated by Norman Tovey-Walsh almost 4 years ago
Line 39, by the way, is
<xsl:sequence select="map { 'language': string($options) }"/>
Updated by Michael Kay almost 4 years 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.
Updated by Norman Tovey-Walsh almost 4 years 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.
Updated by Norman Tovey-Walsh almost 4 years 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.
Updated by Michael Kay almost 4 years ago
- Status changed from In Progress to Closed
Closing this as unresolved.
Updated by Norman Tovey-Walsh almost 4 years ago
I have found a reproducible test case. I'll send it in email.
Please register to edit this issue