Help needed: dynamically counting an attribute

Subject: Help needed: dynamically counting an attribute
From: Ali.Naddaf@xxxxxxxxxxx
Date: Mon, 3 Jul 2000 16:26:37 -0500
Hi everyone. 
I have the following question. Assume that I have the following XML file,
("........" represents some removed irrelevant lines):

<CPU partNum="1345"> 
.............
<CPU partNum="15678">
............
<CPU partNum="1345">
..............
<CPU partNum="11111">
..............
<CPU partNum="11111">
............
<CPU partNum="1345">
..........
<CPU partNum="11111">
.........


and I want to write a stylesheet such that after parsing this XML file, it 

counts the number
of those elements which have the same partNum and report that in some way, 

say in a table 
(in HTML) like the following:

partNum     Qty
1345             3
15678           1
11111           3

The difficulty that I have is the following: I have different XML files 
(with similar structure)
in which, these partNum are different , and may even change in the future, 

so I cannot use a
static counter since I don't know exactly what I should match against (and 

I don't want to hard code all
the possible partNum which may be even unknown!).   I need a smart 
stylesheet
such that it parses the XML file and dynamically, based on whatever number 

appears in partNum
attribute, starts counting them. I hope I am clear about what I need and 
what my problem is. 
I am not picky about the output format, so the above "table" for output 
was just an example to 
show the idea. 

Many thanks, 
Ali Naddaf.


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


Current Thread