[xsl] Problem with iterating through a sequence of integers

Subject: [xsl] Problem with iterating through a sequence of integers
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Mon, 28 Apr 2008 16:20:43 -0400
Hi Folks,

Consider this for-loop which iterates through a sequence.  If the
sequence value is a node then apply-templates is called.  Otherwise,
the value is output:

    <xsl:for-each select="(1, 2, 3)">
        <xsl:choose>
            <xsl:when test=". instance of node()">
                <xsl:apply-templates select="." />
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="."/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:for-each>

When I run Saxon, I get this error message:


Error: Required item type of @select attribute of xsl:apply-templates
is node(); supplied value has item type xs:integer
Failed to compile stylesheet. 1 error detected.


If I comment out the apply-templates statement, the for-loop works
fine.

It also works fine if I add a node to the for-loop's XPath expression,
e.g.

    <xsl:for-each select="(//Book/Author, 1, 2, 3)">

I'm baffled.  Any ideas?

/Roger

Current Thread