Project

Profile

Help

Bug #4605

closed

Spurious error message

Added by Norman Tovey-Walsh almost 4 years ago. Updated almost 4 years 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:
Platforms:

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.

Please register to edit this issue

Also available in: Atom PDF