[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Counting proceding elements with the attribute value

Subject: Counting proceding elements with the attribute value
From: "Niklas Gustavsson" <niklas@xxxxxxxxxxxxx>
Date: Sun, 7 Apr 2002 23:02:47 +0200
proceding
Hi

I'm sure this question have a very simple answer that I have overlooked :-)

I have a XML document with the following structure:
<nodes>
 <node name="a">
  <!-- some XML -->
 </node>
 <node name="b">
  <!-- some XML -->
 </node>
 <node name="b">
  <!-- some XML -->
 </node>
 <node name="b">
  <!-- some XML -->
 </node>
 <node name="c">
  <!-- some XML -->
 </node>
</nodes>

Then I have this XSLT fragment:
<xsl:template match="node">
 <xsl:value-of select="@name" />
 <xsl:if test="following-sibling::attr/@name = @name or
preceding-sibling::attr/@name = @name">
  <!-- here I want to output the number of proceding elements with the same
value in the name attribute -->
 </xsl:if>
</xsl:template>

But, I can not think of any way of getting the number of proceding  elements
with the same value in the name attribute. Or rather, how to select the node
set with that condition.

The final result I want is:
a
b 1 (3)
b 2 (3)
b 3 (3)
c

Any help? :-)

Thanks!
/niklas




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.