<xsl:template match="/">

<xsl:for-each select="addressbook/address">

<xsl:sort select="name/last-name"/>

 

That's how simple it is: <xsl:sort> is child of <xsl:for-each>, sorting the nodes in the nodeset specified (addressbook/address) on one of its subnodes (name/last-name>.

See snippet of xml used below.

<addressbook>
<address>
<name>
<title>Mr.</title>
<first-name>Chester Hasbrouck</first-name>
<last-name>Frisby</last-name>
</name>
<street>1234 Main Street</street>
<city>Sheboygan</city>
<state>WI</state>
<zip>48392</zip>
</address>
<address>
...

 

 

 

 

Report Place comment