[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Sorting on a transformed string?

Subject: RE: Sorting on a transformed string?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Sun, 27 Oct 2002 12:20:58 -0000
xslt sort computed
The simplest way of doing this in XSLT 1.0 is probably to use a
multi-pass transformation. In the first pass, build a temporary tree
containing the computed sort keys. In the second pass (done using
xx:node-set()), do the sort.

In XSLT 2.0 you can compute the sort key using an xsl:function.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Scott Bronson
> Sent: 26 October 2002 17:58
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Sorting on a transformed string?
> 
> 
> Hello.  A sort problem is stumping me right now.  I've got 
> the following
> nodes:
> 
>     <Member name="CreateInstance">
>     <Member name="System.Caption.Insert">
>     <Member name="System.Collections.ICollection.Count"
> 
> I'd like to sort them by name, without leading namespace:
> 
>     Count, CreateInstance, Insert
> 
> Then I'd like to output them, WITH the namespace:
> 
>     System.Collections.ICollection.Count
>     CreateInstance
>     System.Caption.Insert
> 
> Normally, I use leaf-name (below) to trim the namespace.  
> However, I suspect it's impossible to get sort to use a named 
> template, and I haven't figured out any other way of figuring 
> out the leaf name.
> 
> Is possible to sort on the leaf name?  Is it possible in XML 1.0?  :)
> 
> Thank you!
> 
>     - Scott
> 
> 
> 
> <xsl:template name="leaf-name">
>   <xsl:param name="string"/>
>   <xsl:choose>
>     <xsl:when test="substring-after($string,'.')">
>       <xsl:call-template name="leaf-name">
>         <xsl:with-param name="string" 
> select="substring-after($string,'.')"/>
>       </xsl:call-template>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:value-of select="$string"/>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
> 
> 
> 
> 
>  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

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.