|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] AW: sorting AND copying of XML via XSL
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








