This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Sorting across Multiple branches of XML
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: Sorting across Multiple branches of XML
- From: "Chidester, Brice" <Brice dot Chidester at qwest dot com>
- Date: Fri, 9 Jun 2000 09:08:27 -0400
- Reply-To: xsl-list at mulberrytech dot com
I'm wondering if it's possible to use the <xsl:sort> tag to sort elements
that lie across multiple branches of my XML file. For instance, my XML might
look as follows:
<node_list>
<hp>
<hp_node>
<node_name>aaa</node_name>
<type>hp</type>
</hp_node>
<hp_node>
<node_name>ccc</node_name>
<type>hp</type>
</hp_node>
</hp>
<sun>
<sun_node>
<node_name>bbb</node_name>
<type>sun</type>
</sun_node>
</sun>
</node_list>
I currently have an xsl file that appears similar to this:
<xsl:stylesheet>
<xsl:template match="node_list">
<xsl:apply-templates>
<xsl:sort order="descending"
select="node_name"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="hp_node">
<xsl:value-of
select="node_name"/>
<xsl:value-of
select="type"/>
</xsl:template>
<xsl:template match="sun_node">
<xsl:value-of
select="node_name"/>
<xsl:value-of
select="type"/>
</xsl:template>
</xsl:stylesheet>
Currently, my output appears like this:
aaa
hp
ccc
hp
bbb
sun
Is there any way to make it appear like this?:
aaa
hp
bbb
sun
ccc
hp
I'd really appreciate any suggestions anyone could offer. Thanks.
Brice Chidester
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list