[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?

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)
golf.xsl
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.