Subject: Re: [xsl] Sorting on a transformed string? From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 29 Oct 2002 10:25:33 GMT |
> From: Scott Bronson <bronson@xxxxxxxxxxx> > Date: 26 Oct 2002 09:57:54 -0700 > > 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 <x> <Member name="CreateInstance"/> <Member name="System.Caption.Insert"/> <Member name="System.Collections.ICollection.Count"/> </x> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:template match="x"> <xsl:for-each select="Member"> <xsl:sort select="concat( substring-after(substring-after(substring-after(@name,'.'),'.'),'.') , substring-after(substring-after(@name[not(contains(substring-after(substring-after(.,'.'),'.'),'.'))],'.'),'.') , substring-after(@name[not(contains(substring-after(.,'.'),'.'))],'.') , @name[not(contains(.,'.'))] )"/> member: <xsl:value-of select="@name"/> sorted by: <xsl:value-of select="concat( substring-after(substring-after(substring-after(@name,'.'),'.'),'.') , substring-after(substring-after(@name[not(contains(substring-after(substring-after(.,'.'),'.'),'.'))],'.'),'.') , substring-after(@name[not(contains(substring-after(.,'.'),'.'))],'.') , @name[not(contains(.,'.'))] )"/> </xsl:for-each> </xsl:template> </xsl:stylesheet> $ saxon sort.xml sort.xsl <?xml version="1.0" encoding="utf-8"?> member: System.Collections.ICollection.Count sorted by: Count member: CreateInstance sorted by: CreateInstance member: System.Caption.Insert sorted by: Insert David _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Scanning Service. For further information visit http://www.star.net.uk/stats.asp or alternatively call Star Internet for details on the Virus Scanning Service. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Sorting on a transformed , Scott Bronson | Thread | Re: [xsl] Sorting on a transformed , Mitch Amiano |
Re: [xsl] xsl loop with variable, David Carlisle | Date | AW: [xsl] CSV instead of white-spac, Delaney Robin |
Month |