Re: [xsl] XPath problem with getting all ancestors

Subject: Re: [xsl] XPath problem with getting all ancestors
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 23 Oct 2009 11:36:01 +0100
preceding axis includes those nodes that precede the current node, ie
(if you want to think in terms of tags, which XSLT never uses) have an
end tag before teh start tag of tge current element.

Given your sample input

		ancestors="<xsl:value-of select="count(ancestor::*)"/>"
is 4 (document,article,content,para)

		preceding="<xsl:value-of select="count(preceding::*)"/>"
is 3 (headline, title, meta)

		contentNum="<xsl:value-of select="count(preceding::content)"/>"

is 0

  What I actually need to do is to count the number of content nodes
  preceding the current note (relevant for the input XML note numbering
  scheme)

<xsl:number level="any" count="content"/>

probably does what you want.

David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread