Re: [xsl] Grouping upon various attribute values

Subject: Re: [xsl] Grouping upon various attribute values
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 16 Aug 2006 16:13:10 +0100
  <foo a="a" b="b"/>

  and

  <foo b="b" a="a"/>

  are semantically equivalent but the result of string-join(@*,'-')
  would (I think, most of the time) be different, 

depends on the parser ,some routinely stuff attributes in some kind of
hash table and so report them in an order unrelated to the order that
they appear in the file.

However Michael's observation is correct that in this case what matters
is not that the attributes on the same element are reported in the same
order, but that similarly named attributes on different elements are
reported in the same order, and for that you need to sort.

group-by="f:key(@*)" 

<xsl:function name="f:key">
  <xsl:param name="nodes" as="item()*"/>
  <xsl:value-of separator="|">
  <xsl:perform-sort select="$nodes">
  <xsl:sort select="name()"/>
  </xsl:perform-sort>
  </xsl:value-of>
</xsl:function>

Current Thread