[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: Mon, 2 Apr 2001 16:15:53 +0100
Re:  position()
> Well yes, but I would have thought that xsl like

you didn't show the only part of your XSL that matters.
Namely the command that constructs the current node list.
position() counts the position of the current node in the current node
list. It isn't directly tied to the input document or the currently
active template. 

given

<objects>
	<!-- hello -->
	<object name="first"/>
	<object name="second"/>
	<!-- hello -->
	<object name="third"/>
	<object name="fourth"/>
</objects>


if you go <xsl:apply-templates/> then you default to select="node()"
and so the current list is
1 white space
2 comment
3 white space
4 object
5 white space
6 object
...

unless you specified in your stylesheet that white space should be
stripped (or you use MSXML3 which takes a "liberal" reading of the spec on
this point)


If you only want object nodes in your list just select those and have
<xsl:apply-template select="object">

then you get a list
1 object
2 object
...

> Also on a related point how can I output the preceding node if and
> only if it is a comment.

<xsl:copy-of select="preceding::*[1][self::comment()]"/>

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.