This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: position()



> Close. It still needs to co-operate with last() in order to detect the
> last sibling in a sequence, though.

er no last() tells you how many elements are in the current list.
If you want to know how many siblings you have you want count(../*)


> The function you give is actually what I use.

Then you are just using simple cases that position() wasn't particularly
designed for.

In 
<xsl:for-each select="document('a')/x/y | id('b') | //x/z">
<xsl:sort select="@label"/>

then you are going to be processing some list of nodes in some sorted
order. position() and last() let you know how far along that list you've
got. knowing the sibling count of each individual node in the original
document isn't much help. The chances are that position() is what you
want.


> I think this is the problem: XSLT does not treat the document
> structure, it treats the file structure at a much lower level. 

A bizarre description:-) XSLT gives almost no view of the file
structure at all, you only get to see th elogical document tree.


You object to the fact that position() is easier to type than
count(preceding-sibling::*)+1 but I'd argue that position() is
more often what you want. If the current node list is anything other
than simply the list of child elements of a single parent then 
the sibling count is unlikely to be of any importance to the generated
result. In the cases where it is important you can use count() to get
it.


David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]