This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: difficulties with the position() function and xpath statements
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] difficulties with the position() function and xpath statements
- From: David Carlisle <davidc at nag dot co dot uk>
- Date: Fri, 2 Nov 2001 20:31:22 GMT
- References: <MCEHJCJAMLENMMKJOCCHCEIOCBAA.ricks@isogen.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
> position function in my name: <xsl:document
> href="section{position()}.html">
you want to use a number that relates to the position of the node in the
source, eg count(preceding-sibling::section) not position().
position() relates to the position of the node in the current node list
which has no relation to where the node is in the source. If for example
you get to that node by selection .. (or *[1] or section[last()]) then
position() will be 1 as the node sets (and thus the current node list)
selected by those expressions always have at most one node.
If you get to section by select="section" then position() will have the
sibling count of section nodes, but if for example you use the default
selection for apply-templates, position() will count text nodes and
comments as well as all element types, not just section elements.
So basically don't use position() to generate numbers, unless you only
generate them in one place (or you have a good control over the flow of
your stylesheet)
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list