Subject: [xsl] current() and position()? From: "David Birnbaum djbpitt@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Mon, 2 Dec 2019 01:05:11 -0000 |
Dear xsl-list, With apologies for what I suspect is a naive question, I am confused about the context position in: <xsl:variable name="letters" as="xs:string+" select="'a', 'b', 'c'"/> <xsl:for-each select="$letters"> <xsl:message select="position(), current() ! position()"/> </xsl:for-each> position() returns what I expect (1, then 2, then 3), but the value of current() ! position() is always 1. In this test it doesn't matter because I can just use position(), but the real use case requires me to refer the position of the item selected by the <xsl:for-each> at a lower depth (inside a predicate on a different sequence). I can save the value of position() to a variable and use it at that lower depth, so as far as getting the job done there isn't a problem, but getting the job done is less interesting than understanding why my expectation was wrong. I thought that inside an <xsl:for-each> the function current() would refer to the sequence item being processed at the moment (that is, within the parent <xsl:for-each>), and its position would be the context position, that is, its offset into the sequence over which <xsl:for-each> was ranging by means of its @select attribute. I think what I'm seeing instead is that current() ! position() returns the position of the current item inside the one-item sequence being processed at the moment, which is why the value is always 1. Does this mean that the context position (within the sequence selected by the @select attribute on <xsl:for-each>) of the item being processed is not accessible once the processing is deep enough that position() by itself is not longer suitable? If current() is still the current context *item*, where and why does it lose contact with its original context *position*? Best, David
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Thread | Re: [xsl] current() and position()?, Dimitre Novatchev dn | |
Date | Re: [xsl] current() and position()?, Dimitre Novatchev dn | |
Month |