This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Help needed: dynamically counting an attribute
- To: XSL-List at mulberrytech dot com
- Subject: Help needed: dynamically counting an attribute
- From: Ali dot Naddaf at trilogy dot com
- Date: Mon, 3 Jul 2000 16:26:37 -0500
- Reply-To: xsl-list at mulberrytech dot com
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