[oXygen-user] Odd behavior of position() in a predicate

Mark Baker mbaker at analecta.com
Sat Jan 5 10:35:21 CST 2013


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.oxygenxml.com/pipermail/oxygen-user/attachments/20130105/f7daabe0/attachment.html 


More information about the oXygen-user mailing list