xsl-list
[Top] [All Lists]

Aw: [xsl] how to make a group-by multiple attributes motionless

2019-09-25 17:07:22
Use a composite grouping key that spells out attributes in the required order if the names are known.
--
Diese Nachricht wurde von meinem Android Mobiltelefon mit GMX Mail gesendet.
Am 25.09.19, 23:44, "Geert Bormans geert(_at_)gbormans(_dot_)telenet(_dot_)be" <xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> schrieb:
All,

I a streaming XSLT 3.0, I have to group a series of elements by their attribute names and values
I have issues making the group-by motionless

In a simplified example

<rows>
    <row a="val-a-1" b="b-val"/>
    <row a="val-a-2" b="b-val"/>
    <row a="val-a-1" b="b-val"/>
    <row a="val-a-2"/>
</rows>

I need grouping this way

<rowgroups>
   <rowgroup hash="|a=val-a-1|b=b-val"/>
   <rowgroup hash="|a=val-a-2|b=b-val"/>
   <rowgroup hash="|a=val-a-2"/>
</rowgroups>

easily achieved this way

             <xsl:fork>
                <xsl:for-each-group select="*" group-by="string-join(@*/concat('|', name(), '=', .), '')">
                    <rowgroup hash="{current-grouping-key()}"/>
                </xsl:for-each-group>
            </xsl:fork>

but, I could have data like this (third line attribute order swapped)

<rows>
    <row a="val-a-1" b="b-val"/>
    <row a="val-a-2" b="b-val"/>
    <row b="b-val" a="val-a-1"/>
    <row a="val-a-2"/>
</rows>

and this basically gives me a fourth group using the code above

So I want to make sure that the attributes order can be controlled when I prepare the group-by, but any sorting attempt I make, leads to the group-by no longer being motionless

I would welcome your suggestions

Thanks

Met vriendelijke groeten,
Best regards,

Geert Bormans
<Prev in Thread] Current Thread [Next in Thread>
  • Aw: [xsl] how to make a group-by multiple attributes motionless, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de <=