xsl-list
[Top] [All Lists]

RE: calculate unique items in xsl

2002-10-10 13:05:43
Try something like this:

<xslt:value-of 
select="count(/inventory//warehousecode[not(preceding::warehousecode = .)])"/>

Someone else might come up with something more efficient ...

Rich
 
-----Original Message-----
From: RJ P [mailto:peterson_rj(_at_)hotmail(_dot_)com] 
Sent: Thursday, October 10, 2002 12:42 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com


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


_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


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




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



<Prev in Thread] Current Thread [Next in Thread>