Re: [xsl] position()

Subject: Re: [xsl] position()
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 2 Apr 2001 16:15:53 +0100
> 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. 


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

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()]"/>


This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit

 XSL-List info and archive:

Current Thread