Subject: Re: What will be the future improvements of XSLT? From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 16 Sep 1999 16:23:11 +0100 (BST) |
> I am trying very hard not to use extension functions. I agree, one could imagine though an XSL n+1 allowing extension functions written in xsl, ie essentially just syntactic sugar for calling a named template. > Going back to the original question; other than using > extension functions, can I do this kind of sorting in XSLT at all? as always there is the more or less inelegant solution of using the only datatype over which you have real programatic control, namely strings. If you had a function that mapped your enumerated type to the numbers 1 2 3 then you could use that in the sort specification. given <xsl:variable name="tour" select= "'PGA1:LPGA2:Senior PGA3:'"/> then substring-before(substring-after($tour,@tour),':') is just such a function, and <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0" > <xsl:variable name="tour" select= "'PGA1:LPGA2:Senior PGA3:'"/> <xsl:template match="test"> <xsl:apply-templates select="xxx"> <xsl:sort select="substring-before(substring-after($tour,@tour),':')"/> <xsl:sort select="@name"/> </xsl:apply-templates> </xsl:template> <xsl:template match="xxx"> [<xsl:value-of select="@tour"/>, <xsl:value-of select="@name"/>] </xsl:template> </xsl:stylesheet> converts <test> <xxx tour="LPGA" name="y"/> <xxx tour="LPGA" name="x"/> <xxx tour="Senior PGA" name="x"/> <xxx tour="PGA" name="y"/> <xxx tour="Senior PGA" name="y"/> <xxx tour="PGA" name="x"/> <xxx tour="PGA" name="z"/> </test> to bash-2.01$ xt golf.xml golf.xsl [PGA, x] [PGA, y] [PGA, z] [LPGA, x] [LPGA, y] [Senior PGA, x] [Senior PGA, y] bash-2.01$ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: What will be the future improve, Khun Yee Fung | Thread | RE: What will be the future improve, Kay Michael |
RE: What will be the future improve, Kay Michael | Date | RE: Combine Java and XSL: to put co, Siegfried Haag |
Month |