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

Counting uniquely selected values of elements

Subject: Counting uniquely selected values of elements
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Mon, 14 Apr 2003 12:45:16 +0000
count selected values
Hi all,

I have tried to make a subject title as descriptive as possible, but I don't know if I have succeded very well.

Anyway, here is my problem:

I have a source.xml that has the following structure:

<root>
 <a><b><c>this</c></b></a>
 <a><b><c>that</c></b></a>
 <a><b><c>that</c></b></a>
 <a><b><c>not this</c></b></a>
 <a><b><c>not that</c></b></a>
 <a><b><c>this</c></b></a>
 <a><b><c>this</c></b></a>
</root>

I want to count the occurences of each text in the c element (this, that, not this, not that).

I have tried something like:

<xsl:template match="/">
 <xsl:apply-templates select="root"/>
</xsl:template>

<xsl:template match="root">
<xsl:apply-templates select="a/b/c[not(preceeding::a/b/c)]"/>
<!-- This is not right, but I don't have any clue what to put into the select statement -->
</xsl:template>


<xsl:template match="a/b/c">
 <xsl:value-of select="."/> occurs
 <xsl:value-of select="count(preceeding::a/b/c=.)"/> times.
 <!-- Syntax is not right here either -->
</xsl:template>

It is especialy the nested a/b/c (instead of just c) that throws me off, but I have never tried counting either.

Thanks in advance!

Ragulf Pickaxe :)

_________________________________________________________________



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.