Subject: RE: [xsl] Sorting problems [was: Choosing different sorts] From: "Michael Kay" <mhk@xxxxxxxxx> Date: Fri, 16 Jul 2004 12:10:40 +0100 |
You have set a variable to the string sml:meta/sml:designer/sml:name You are then testing whether the name of an element is equal to this string. The name of an element never has a "/" in it, so this test can never succeed. Michael Kay > -----Original Message----- > From: Derek Hohls [mailto:DHohls@xxxxxxxxxx] > Sent: 16 July 2004 09:56 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] 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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Sorting problems [was: Choosi, Derek Hohls | Thread | Re: [xsl] Sorting problems [was: Ch, David Carlisle |
[xsl] Sorting problems [was: Choosi, Derek Hohls | Date | Re: [xsl] Sorting problems [was: Ch, David Carlisle |
Month |