[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to sort a nodeset returned by key()?
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"> <xsl:output method="xml" indent="yes" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" omit-xml-declaration="yes" /> <xsl:strip-space elements="*"/> <xsl:key name="accounts-by-region" match="/demo/salesman/account" use="@region"/> <xsl:template match="/demo"> <html> <head><title>Accounts ordered by region</title></head> <body> <table border="1" valign="top"> <tr><th>Region</th><th>Account</th></tr> <xsl:for-each select="salesman/account[count(. | key('accounts-by-region',@region)[1]) = 1]"> <xsl:sort select="@region"/> <xsl:for-each select="key('accounts-by-region',@region)"> <xsl:sort select="."/> <tr> <xsl:if test="position()=1"> <td rowspan="{last()}"> <xsl:value-of select="@region"/> </td> </xsl:if> <td><xsl:value-of select="."/></td> </tr> </xsl:for-each> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet> David
|
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
|