Hi Marcel,
Now I want to sort the bar elements and then the item elements
according to their Id's, and finally output
the entire document sorted, e.g.
Think, there are better and shorter implementations do this, but this
might be one way to come by:
<xsl:output method="xml"/>
<xsl:template match="/foo">
<xsl:element name="foo">
<xsl:for-each select="bar">
<xsl:sort select="@id" order="ascending"></xsl:sort>
^^^^^^^^^^^
<xsl:element name="bar">
<xsl:attribute name="id"><xsl:value-of
select="@id"/></xsl:attribute>
<xsl:for-each select="item">
<xsl:sort select="@id"
order="ascending"></xsl:sort>
^^^^^^^^^^^
<xsl:element name="item">
<xsl:attribute
name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:value-of
select="item"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
Just put two sorted for-each-loops together and produce the output via
<xsl:element> and <xsl:attribute>. This produces the exactly the xml you
wanted. Or what else problem did you have with it?
Hendrik Beck
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list