[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Sorting problems [was: Choosing different sorts]
Apologies for not replying to the thread, but I am on the daily digest and not sure how to respond appropriately. Thanks to all for the suggestions, I have tried to implement them, but now I get no results. This is the XML: <?xml version="1.0" encoding="ISO-8859-1"?> <scenarios> <file name="scen03.xml"> <sml:meta xmlns:sml="http://www.test.com/"> <sml:designer id="mm"> <sml:name>Mr Mustard</sml:name> </sml:designer> </sml:meta> <sml:scenario xmlns:sml="http://www.test.com" status="test" version="1"> <sml:name>My New Scenario</sml:name> </sml:scenario> </file> <file name="scen01.xml"> <sml:meta xmlns:sml="http://www.test.com"> <sml:designer id="jc"> <sml:name>Joe Cool</sml:name> </sml:designer> </sml:meta> <sml:scenario xmlns:sml="http://www.test.com" status="draft" version="1"> <sml:name>Test 102</sml:name> </sml:scenario> </file> <file name="scen02.xml"> <sml:meta xmlns:sml="http://www.test.com"> <sml:designer id="fw"> <sml:name>Fred E. Wally</sml:name> </sml:designer> </sml:meta> <sml:scenario xmlns:sml="http://www.test.com" status="final" version="1"> <sml:name>Scenario #2</sml:name> </sml:scenario> </file> </scenarios> And this is the XSL: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sml="http://www.test.com" > <!-- request parameters --> <xsl:param name="sort">stat</xsl:param> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> <xsl:template match="scenarios"> <html> <head> <title>Scenario List</title> </head> <body> <div align="center"> <h1>Scenario List</h1> <table summary="Scenario List" cellpadding="4" cellspacing="0"> <tr> <th>Name</th> <th>Designer</th> <th>Status</th> </tr> <!-- should work, but does not seem to sort?? --> <xsl:variable name="sortkey"> <xsl:choose> <xsl:when test="$sort='design'">sml:meta/sml:designer/sml:name</xsl:when> <xsl:when test="$sort='stat'">sml:scenario/@status</xsl:when> <xsl:otherwise>sml:scenario/sml:name</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:for-each select="file"> <xsl:sort select="*[name(.) = $sortkey]"/> <!-- THIS DOES WORK, but does not handle different sorts <xsl:for-each select="file"> <xsl:sort select="sml:scenario/sml:name"/> --> <tr> <td><xsl:value-of select="sml:scenario/sml:name"/></td> <td><xsl:value-of select="sml:meta/sml:designer/sml:name"/></td> <td><xsl:value-of select="sml:scenario/@status"/></td> </tr> </xsl:for-each> </table> </div> </body> </html> </xsl:template> <!-- scenario files --> <xsl:template match="file"> </xsl:template> </xsl:stylesheet> Any help with this would be appreciated! Thanks Derek -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. MailScanner thanks transtec Computers for their support.
|
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
|