[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Proper syntax for counting all prior nodes in XPath? (revised)
Subject: [xsl] Proper syntax for counting all prior nodes in XPath? (revised) From: Jason Morris <jason.morris@xxxxxxxxxxxxxx> Date: Tue, 12 Jun 2001 11:50:35 -0600 |
Thanks for the help on my original problem. I would now like to revise it slightly, which makes it more complicated (for a beginner like me, anyway). 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> <CHAPTER> <SECTION> <PAGE> <LINE>Test 4</LINE> <LINE>Test 5</LINE> </PAGE> </SECTION> <SECTION> <PAGE> <LINE>Test 6</LINE> </PAGE> </SECTION> </CHAPTER> </DOC> How can my XSL count all the preceding nodes within the same chapter? For example, when my template is processing the <LINE>Test 6</LINE>, I want to count all nodes before it within the current <CHAPTER> tag. Therefore, it would be 2 <LINE>s, 2 <PAGE>s, 2 <SECTION>s, and 1 <CHAPTER>. Does this make sense? Originally I wanted all prior nodes. Now I want to restrict my prior nodes to within a specific ancestor. I was originally using <xsl:variable name="num_rows" select="count(preceding::LINE)+count(preceding::PAGE)+count(preceding::SECTI ON)+count(preceding::CHAPTER)"/> as recommended by another list member. But this counts everything, not just within the current <CHAPTER> node. What is the most efficient way of modifying it to count only the prior nodes in the current <CHAPTER>? Thanks Jason XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Accessing array variable, Goetz Bock | Thread | RE: [xsl] Proper syntax for countin, Michael Kay |
Re: [xsl] Accessing array variable, Goetz Bock | Date | RE: [xsl] Proper syntax for countin, Michael Kay |
Month |