xsl-list
[Top] [All Lists]

Re: [xsl] Grouping upon various attribute values

2006-08-16 06:59:08
On 8/16/06, lawrence(_dot_)michel(_at_)post(_dot_)ch 
<lawrence(_dot_)michel(_at_)post(_dot_)ch> wrote:
Hi all,

I have a little problem, which gives me a bit headache at the moment.
Maybe you could help me solve it :

Here the given XML :

                <produktenZumAnalysieren>
                        <gesamtMenge>
                                <filter aufAttribut="Name_Stat"
typ="diskret" wertStruktur="baum" wert="BP"/>
                                <filter aufAttribut="FrankaturArt"
typ="diskret" wertStruktur="genau" wert="PP"/>
                        </gesamtMenge>
                </produktenZumAnalysieren>
                <produktenZumAnalysieren>
                        <gesamtMenge>
                                <filter aufAttribut="Name_Stat"
typ="diskret" wertStruktur="baum" wert="BP"/>
                                <filter aufAttribut="FrankaturArt"
typ="diskret" wertStruktur="genau" wert="PP"/>
                        </gesamtMenge>
                </produktenZumAnalysieren>
                <produktenZumAnalysieren>
                        <gesamtMenge>
                                <filter aufAttribut="Name_Stat"
typ="diskret" wertStruktur="baum" wert="BP"/>
                                <filter aufAttribut="Gewicht"
typ="interval" wert_Ab="1" wert_Bis="100"/>  //<- Careful here, there is
a new set of attributes
                        </gesamtMenge>
        </produktenZumAnalysieren>

As you can see, there are three "gesamtMenge" elements, each in its own
"ProduktZumAnalysieren" element.

Now, I would like to apply a for-each-group loop on them :

        <xsl:for-each-group select="produktenZumAnalysieren"
group-by="gesamtMenge/filter/@* (KICKME HERE)">

That is, the grouping key isn't doing what I expect: I need to have all
attributes taken in consideration for grouping the required elements. In
this example, I should have two distinctive groups

As you have two attributes you need to combine them to form the grouping key:

<xsl:for-each-group select="produktenZumAnalysieren"
 group-by="string-join(gesamtMenge/filter/@aufAttribut, '-')">

untested.

cheers
andrew

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