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

Re: position() returns what?

Subject: Re: position() returns what?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 24 Oct 2003 10:03:39 +0100
xsl position value template

> But this outputs equal numbers: 2,4,6,8,10,...
> I did expect that it would output 0,1,2,3,4,5

This is a FAQ (I'm sure itmustbe in teh faq file for this list)
position() returns a number that is not a property of teh node (teh same
node can have any number of position() values, for example if you select
it with .. or . it always has position() =1.

position() returns the position of the node in the current node list,
and if that is the default selection for apply-templates this is
child::node(0 which is all nodes including text nodes, so
in your case the odd numbered nodes are all white space text nodes, if
you added a template for them,
<xsl:template match="text()">
     <xsl:value-of select="position()"/>
then you'd see it.

change you apply tempaltes to use select="*" if you only want to process
element children, or use xsl:strip-space to discard teh white space
before processing begins.

David

-- 
http://www.dcarlisle.demon.co.uk/matthew

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 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.