W3C home > Mailing lists > Public > xsl-editors@w3.org > January to March 2001

RE: xslt 1.1

From: Michael Kay <mhkay@iclway.co.uk>
Date: Wed, 31 Jan 2001 18:10:38 -0000
To: "'Matthew Bentley'" <matthew.bentley@brookers.co.nz>
Cc: <xsl-editors@w3.org>
Message-ID: <000701c08bb1$8a93fb00$0100007f@oemcomputer>
> There is needed, ...
> the ability for position() to take a node as an argument, and
> return the -relative- position.
> For example:
> <xsl:value-of select="position(following-sibling::truck[1])" />
> would return: "3"

The result, of course, is a function not only of the target node, but of the
axis by which it was reached; and presumably it would count all nodes along
that axis (including comments), rather than merely counting elements?
Defining such a function would get very complex and might well give answers
that were intuitively wrong in many cases.

I think a much more general capability is the idea of a "truncated axis", so
you could select the node-set

leading(following-sibling::*, [not(self::truck)])

which selects all following sibling elements up to the first one that is a
<truck>, and then you can do count() on this to get your position()

If you want to play with this, there's an extension function saxon:leading()
that works like this in Saxon.

Mike Kay
Received on Wednesday, 31 January 2001 13:12:06 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:44:21 UTC