This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
<xsl:sort> question.
- From: "Dung, Ming-tzung" <Ming-tzung_Dung at jdedwards dot com>
- To: "XSLT List (E-mail)" <XSL-List at lists dot mulberrytech dot com>
- Date: Fri, 19 Apr 2002 10:54:24 -0600
- Subject: [xsl] <xsl:sort> question.
- Reply-to: xsl-list at lists dot mulberrytech dot com
The version 1 will work and the version 2 will not sort the data, even
though I think that these two are logically equivalent.
Please let me know what you think? Thanks in advance!!
------
**Version1 - output the sorted last name**
<xsl:template match="/">
<xsl:for-each select="addressbook/address">
<xsl:sort select="name/last-name"/>
<p>
<xsl:value-of select="name/last-name"/>
</p>
</xsl:for-each>
</xsl:template>
**Version 2 - output the sorted last name**
<xsl:template match="/addressbook/address">
<xsl:for-each select=".">
<xsl:sort select="name/last-name"/>
<p>
<xsl:value-of select="name/last-name"/>
</p>
</xsl:for-each>
</xsl:template>
**Input xml data
-----
<?xml version="1.0"?>
<addressbook>
<address>
<name>
<title>Mr.</title>
<first-name>Chester Hasbrouck</first-name>
<last-name>Frisby</last-name>
</name>
</address>
<address>
<name>
<first-name>Harry</first-name>
<last-name>Backstayge</last-name>
</name>
</address>
<address>
<name>
<first-name>Mary</first-name>
<last-name>McGoon</last-name>
</name>
</address>
<address>
<name>
<title>Ms.</title>
<first-name>Amanda</first-name>
<last-name>Reckonwith</last-name>
</name>
</address>
</addressbook>
-----
Ming
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list