xsl-list
[Top] [All Lists]

[xsl] grouping and counting of elements

2007-04-20 07:02:08
Hi experts,
I have seen similar questions to mine, yet didn't find a good mach.
Please point to the right thread if exists.
I have a source Xml:


<All_Results>
  <Result>
     <Name>John</Name>
     <Country>UK</Country>
<!-- other upto 100 elements -->
     <Color>Red</Color>
  </Result>
  <Result>
     <Name>John</Name>
     <Country>US</Country>
<!-- other upto 100 elements -->
     <Color>Green</Color>
  </Result>
  <Result>
     <Name>Thomas</Name>
     <Country>Estonia</Country>
<!-- other upto 100 elements -->
     <Color>
     </Color>
  </Result>
  <Result>
     <Name>
     </Name>
     <Country>UK</Country>
<!-- other upto 100 elements -->
     <Color>Red</Color>
  </Result>
</All_Results>

Each <Result> has the same list of sub-elements, some might not have a
text value

I want to aggregate and get something like this:

<Totals>
  <Name>
     <Tag value="John" count="2" />
     <Tag value="Thomas" count="1" />
  </Name>
  <Country>
     <Tag value="UK" count="2" />
     <Tag value="US" count="1" />
     <Tag value="Estonia" count="1" />
  </Country>
  <Color>
     <Tag value="Red" count="2" />
     <Tag value="Green" count="1" />
  </Color>
<!-- other elements grouped by element name, sorted by total of
element values-->
</Totals>

Please advice.
Thanks,
Leonid

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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