|
[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: calculate unique items in xsl
Subject: Re: calculate unique items in xsl
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 10 Oct 2002 22:13:16 +0200
|
Yes, <xsl:key> (Muenchian Method) is a good approach for your grouping
problem:
<xsl:key name="items" match="item" use="warehousecode"/>
<xsl:template match="inventory">
Number of unique warehouse codes: <xsl:value-of
select="count(item[generate-id() = generate-id(key('items',
warehousecode))])"/>
</xsl:template>
(untested)
Regards,
Joerg
RJ P wrote:
Thanks for your help in my previous post! Given the below xml,how can I
get the
the number of unique warehouse codes? Do I need to use <xsl:key>?
<inventory>
<item>
<warehousecode>BA</warehousecode>
<item>bolt</item>
<quantity>34</quantity>
</item>
<item>
<warehousecode>BA</warehousecode>
<item>nail</item>
<quantity>50</quantity>
</item>
<item>
<warehousecode>AC</warehousecode>
<item>tack</item>
<quantity>5</quantity>
</item>
<item>
<warehousecode>BA</warehousecode>
<item>hammer</item>
<quantity>10</quantity>
</item>
<item>
<warehousecode>AD</warehousecode>
<item>screwdriver</item>
<quantity>60</quantity>
</item>
<item>
<warehousecode>AB</warehousecode>
<item>wrench</item>
<quantity>13</quantity>
</item>
</inventory>
Desired output:
Number of unique warehouse codes: 4
Thanks for helping an xsl newbie!!
RJ
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list

|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
| RSS 2.0 |
|
| Atom 0.3 |
|
|