[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: position()

Subject: Re: position()
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 3 Apr 2001 11:37:08 +0100
xsl detecting position in count
> 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.