On 21/05/2015 11:46, Jorge . chocolate(_dot_)camera(_at_)gmail(_dot_)com wrote:
<xsl:variable name="POSITION" select="position()" as="xs:integer"/>
<xsl:sequence select="$FOO[$POSITION]"/>
but I somehow feel that there must be a way to call the `position()`
of the current node from inside those brackets
Interestingly my immediate reaction, "$FOO[current()/position()]" isn't
right. current() does indeed give the XSLT context item, but as a
sequence of item(), i.e. a singleton sequence, so it has a position of 1
within the scope of the /.
Thus the top-level XPath expression position() = current()/position(),
within some XSLT iteration is not (usually) true.
Michael Kay states "in practice it's very rare to write an expression on
the right-hand side of <</>> that depends upon the context position or
size" on p 603 of the 4th Edition of his XSLT2.0 Programmer's Reference.
In years of working with XSLT I hadn't looked at this issue in any
detail. When something didn't work as anticipate either I used the XSLT
variable binding or in XSLT 3 use a local let, as Martin Honnen
suggested. ;-)
--
*John Lumley* MA PhD CEng FIEE
john(_at_)saxonica(_dot_)com <mailto:john(_at_)saxonica(_dot_)com>
on behalf of Saxonica Ltd
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--