This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Proper syntax for counting all prior nodes in XPath?
- To: "'XSL-List at lists dot mulberrytech dot com'" <XSL-List at lists dot mulberrytech dot com>
- Subject: [xsl] Proper syntax for counting all prior nodes in XPath?
- From: Jason Morris <jason dot morris at directwest dot com>
- Date: Mon, 11 Jun 2001 11:16:17 -0600
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi,
With an XML document like this:
<DOC>
<CHAPTER>
<SECTION>
<PAGE>
<LINE>Test</LINE>
<LINE>Test 2</LINE>
</PAGE>
</SECTION>
<SECTION>
<PAGE>
<LINE>Test 3</LINE>
</PAGE>
</SECTION>
</CHAPTER>
</DOC>
How can my XSL count all the preceding nodes? For example, when my template
is processing the <LINE>Test 3</LINE>, I want to count all nodes before it,
which would be 2 <LINE>s, 2 <PAGE>s, 2 <SECTION>s, 1 <CHAPTER>, and 1 <DOC>.
Does this make sense?
It would be something like <xsl:number level="any"
count="DOC|CHAPTER|SECTION|PAGE|LINE"/>, except I want to use the count in
an <xsl:if />, not just display it. I have tried using <xsl:if
test="count(something)">, but I do not know what the proper "something" is.
Any suggestions?
Thanks
Jason
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list