This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sort



If the depth of the sorting-element can be bounded to e.g. 3 :
First, parse your sort specification (e.g., 'person.superlogin.login') into
several variables - in this case it would give :
$sortdepth=3
$sortering1='person'
$sortering2='superlogin'
$sortering3='login'
For a simpler sort, e.g. on 'person' it would give :
$sortdepth=1
$sortering1='person'
$sortering2=''
$sortering3=''
This is easy to do with substring-before() and substring-after(), so I'll
leave it as an exercise :-)

Then you can use the following :

 <xsl:apply-templates>
   <xsl:sort select="*[name()=$sortering1 and $sortdepth=1]"
order="{$direction}"/>
   <xsl:sort select="*[name()=$sortering1 and
$sortdepth=2]/*[name()=$sortering2]" order="{$direction}"/>
   <xsl:sort select="*[name()=$sortering1 and
$sortdepth=3]/*[name()=$sortering2]/*[name()=$sortering3]"
order="{$direction}"/>
 </xsl:apply-templates>

Hope this helps.
--Jonathan

----- Original Message -----
From: "Frederic Leclercq" <frederic@ictportal.com>
To: <xsl-list@lists.mulberrytech.com>
Sent: Saturday, February 02, 2002 1:24 AM
Subject: [xsl] sort
>
> that's one "record" - i have 100's of them in the XML string.
>
> Following works perfect if i would like to sort on one of the first level
tags...
> <xsl:apply-templates>
>   <xsl:sort select="*[name()=$sortering]" order="{$direction}"/>
> </xsl:apply-templates>
>
> But now i would like to sort the xmlstring on
"root.person.supelogin.login"
> Anybody could help me out ?
>
> Thx,
> Fred.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]