xsl-list
[Top] [All Lists]

[xsl] RE : [xsl] Grouping upon various attribute values

2006-08-16 07:50:38
Well, here are my results:

1. group-by="string-join(gesamtMenge/filter/@*, '|')"

It worked very well, but the ordering issue is still open. In my case, the xml 
is computationaly created, and ordering of attributes should be maintained 
constantly.

2. group-by="concat(gesamtMenge/filter/@aufAttribut, '|', 
gesamtMenge/filter/@typ, '|', gesamtMenge/filter/@wertStruktur...)"

Doesn't solve my problem: I get the "A sequence of more than one item is not 
allowed as the first argument of concat()". This might be due to the element 
structure of the given nodeset -> the grouping element can contain more than 
one child element where the grouping key is applied.

3. group-by="f:all-attributes(gesamtMenge/filter)"

I get the same issue as 2.

4. Nested groups technique :

I think this can not solve my problem, because attribute sequence is variable. 
Isn't it?


Thank you for your help

Regards from the "cheesy" land ;-)

Lawrence

-----Message d'origine-----
De : Michael Kay [mailto:mike(_at_)saxonica(_dot_)com] 
Envoyé : mercredi, 16. août 2006 15:55
À : xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Objet : RE: [xsl] Grouping upon various attribute values


There's no direct support for composite grouping keys in xsl:for-each-group.
The simplest solution is to form the composite key yourself. The following
looks promising:

group-by="string-join(@*, '|')" 

but is wrong, because the result depends on attribute order. If you know
what attributes you're interested in, use

group-by="concat(@aufAttribut, '|', @typ, '|', @wertStruktur...)"

Alternatively:

group-by="f:all-attributes(.)"

<xsl:function name="f:all-attributes" as="xs:string">
  <xsl:param name="node" as="element()"/>
  <xsl:value-of>
    <xsl:for-each select="$node/@*">
      <xsl:sort select="namespace-uri()"/>
      <xsl:sort select="local-name()"/>
      <xsl:value-of select="."/>
      <xsl:text>|</xsl:text>
    </xsl:for-each>
  </xsl:value-of>
</xsl:function>

The other approach is nested groups:

<xsl:for-each-group group-by="@aufAttribute">
  <xsl:for-each-group select="current-group()" select="@typ">
    <xsl:for-each-group select="current-group()" select="@wertStruktur">
      ...

Michael Kay
http://www.saxonica.com/


-----Original Message-----
From: lawrence(_dot_)michel(_at_)post(_dot_)ch 
[mailto:lawrence(_dot_)michel(_at_)post(_dot_)ch] 
Sent: 16 August 2006 14:26
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Grouping upon various attribute values

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

Any help would be really greatfull ;-)

Cheers

Lawrence Michel, Bern, Switzerland

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



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


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