Subject: RE: Sorting revisited (<xsl:sort>) From: r.mcarthur@xxxxxxxxxxxx Date: Tue, 30 Nov 1999 12:34:40 -0500 |
Correction to code fragment: I made a mistake typing in the sample code fragment with <xsl:apply-templates /> <xsl:param name="sortby"></xsl:param> <xsl:param name="datatype">number</xsl:param> <xsl:param name="orderby">descending</xsl:param> <!-- the important part is as follows --> <xsl:template match="/"> <!-- snip --> <xsl:apply-templates> <xsl:sort select="*[local-name()=string($sortby)]" data-type="{$datatype}" order="{$orderby}" /> </xsl:apply-templates> <!-- snip --> </xsl:template> -----Original Message----- From: r.mcarthur@xxxxxxxxxxxx [mailto:r.mcarthur@xxxxxxxxxxxx] Sent: Tuesday, November 30, 1999 10:51 AM To: xsl-list@xxxxxxxxxxxxxxxx Subject: Sorting revisited (<xsl:sort>) I've searched through the archive and haven't found how to do the following dynamic sorting: I have a document like this: <doc> <orderdata> <item1> </item1> <item2> </item2> ..etc.. </orderdata> </doc> The tags <item1>, <item2>, can have any legal XML tag name, and there can be any number of them (I personally would like to re-write to XML document so I can make a DTD, but have to work with what I have). The XSL output I made so far is a table with the tag names as headers, and allows 'text ascending' sorting on any column. I need to extend this to allow ascending/descending switching and text/number switching. I'm currently passing in parameters into the template, but can't seem to get them to work for the data-type and order attributes of <xsl:sort> The params are passed into the template. <xsl:param name="sortby"></xsl:param> <xsl:param name="datatype">number</xsl:param> <xsl:param name="orderby">descending</xsl:param> <!-- the important part is as follows --> <xsl:template match="/"> <!-- snip --> <xsl:apply-templates /> <xsl:sort select="*[local-name()=string($sortby)]" data-type="{$datatype}" order="{$orderby}" /> <!-- snip --> </xsl:template> The XSL spec says that data-type and order can use attribute value templates, but the above code doesn't work (defaults are used instead). I'm using XT version 19991105, and have already tried the following: 1. remove { } 2. put quotes around param values 3. used select="descending" for param 4. used order="string($orderby)" 5. used order="string({$orderby})" 6. used order="{string($orderby)}" ... and probably some I've forgotten. What am I not understanding about attribute value templates? Thanks in advance, Rob McArthur r.mcarthur@xxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Sorting revisited (<xsl:sort>), Mike Brown | Thread | Re: Sorting revisited (<xsl:sort>), David Carlisle |
RE: Sorting revisited (<xsl:sort>), Mike Brown | Date | RE: Sorting revisited (<xsl:sort>), r . mcarthur |
Month |