Can anyone account for the behavior exhibited by the position function in a predicate in the following code sample:

 

<xsl:variable name="x" select="'A', 'B', 'C'" as="xs:string*"/>

<xsl:variable name="y" select="'a', 'b', 'c'" as="xs:string*"/>

<xsl:for-each select="$x">

                <xsl:variable name="pos" select="position()"/>

                <xsl:message select="position()"/>

                <xsl:message select="., $y[position()]"/>

                <xsl:message select="., $y[$pos]"/>

</xsl:for-each>

 

As the output below shows, when the value of position is stored in a variable and the variable is used in a predicate, you get what you would expect, the selection of a single item corresponding to the current position. But when position() is used directly in the predicate, it returns all the items in the sequence:

 

[Saxon-PE] 1

[Saxon-PE] A a b c

[Saxon-PE] A a

[Saxon-PE] 2

[Saxon-PE] B a b c

[Saxon-PE] B b

[Saxon-PE] 3

[Saxon-PE] C a b c

[Saxon-PE] C c

 

Any ideas, or is this simply a bug?

 

Mark