|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: What will be the future improvements of XSLT?
> 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
|
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
|

Cart








