<xslTutorial creator="nicmila@idoox.com" zvonId="MNaaaa">
<index keywords='xsl:sort xsl:for-each'/>
<description>Nodes selected with xsl:for-each (<stylesheet id='id4'/> and <stylesheet id='id5'/>) or xsl:apply-templates (<stylesheet id='id6'/>) can be sorted. Order of sorting determines order attribute. <stylesheet id='id4'/> sorts in ascending and <stylesheet id='id5'/> in descending mode.</description>
<xmlSource id="id3">
<name>John</name>
<name>Josua</name>
<name>Charles</name>
<name>Alice</name>
<name>Martha</name>
<name>George</name>
</xmlSource>
<attValues>
<value match="//name">matches any name element anywhere in the document.
</value>
<value match="/">matches the root element.
</value>
<value match=".">matches the current element. In this case it maches the name element.
</value>
</attValues>
<xslStylesheet id="id4">
<xsl:template match="/">
<TABLE>
<xsl:for-each select="//name">
<xsl:sort order="ascending" select="."/>
<TR><TH><xsl:value-of select="."/></TH></TR>
</xsl:for-each>
</TABLE>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id5">
<xsl:template match="/">
<TABLE>
<xsl:for-each select="//name">
<xsl:sort order="descending" select="."/>
<TR><TH><xsl:value-of select="."/></TH></TR>
</xsl:for-each>
</TABLE>
</xsl:template>
</xslStylesheet>
<xslStylesheet id="id6">
<xsl:template match="/">
<TABLE>
<xsl:apply-templates select="//name">
<xsl:sort order="descending" select="."/>
</xsl:apply-templates>
</TABLE>
</xsl:template>
<xsl:template match="name">
<TR><TH><xsl:value-of select="."/></TH></TR>
</xsl:template>
</xslStylesheet>
</xslTutorial>