xsl-list
[Top] [All Lists]

[xsl] grouping with xslt 1.0

2009-09-23 05:56:49
Hello,

I am used to write stylesheets with xslt 2.0 but unfortunately I have to do some grouping with xslt 1.0 using the Xalan XSLT Prozessor.
Here is my input:

<data>
   <product id="1">
       <seta numer="5">
       ...
       </seta>
       <seta number="9">
           <element>
               <name>A</name>
               <properties>...</properties>
           </element>
       </seta>
       <setc>....</setc>
   </product>
   <product id="2">
       <seta numer="5">
       ...
       </seta>
       <seta number="9">
           <element>
               <name>B</name>
               <properties>...</properties>
           </element>
       </seta>
       <setc>....</setc>
   </product>
   <product id="3">
       <seta numer="5">
       ...
       </seta>
       <seta number=9>
           <element>
               <name>A</name>
               <properties>...</properties>
           </element>
       </seta>
       <setc>....</setc>
   </product>
</data>

There are three "product" elements which hold "seta" and "setc" tags. Within the "seta" tag there is a name by which the products should be grouped. All products with the same name hold the same "seta" elements but different "setc" elements. So I want to create for both "product" elements with the same name (A) a new element "konto" with attribute "name=A". The konto element holds the "seta" elements which are identical or "A" and "B" and the two(!) "setc" elements. One setc from A and one from B.

The result should look like this:
<data>
   <konto name="A">
       <seta number="5">
       ...
       </seta>
       <seta number=9>
           <element>
               <name>A</name>
               <properties>...</properties>
           </element>
       </seta>
       <setc>...</setc>
       <setc>...</setc>
   </konto>
   <konto name="B">
       <seta numer="5">
       ...
       </seta>
       <seta number=9>
           <element>
               <name>B</name>
               <properties>...</properties>
           </element>
       </seta>
       <setc>....</setc>
   </konto>
</data>

<konto name="A"> holds the "seta" element and both "setc" elements.
What's the best way to create such a grouping? The input file can be large (>2MB) and the number of different names is unknown.

I guess the first step ist to find out what the differrent names are. Is it a good method to create a string that holds the different names (one entry for each name) and than create the grouping by iterating over the names in the string?

Any help is highly appreciated.

regards,
Garvin



--~------------------------------------------------------------------
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>