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

Re: Conditional xsl:sort and leaving some items out of

Subject: Re: Conditional xsl:sort and leaving some items out of sorting
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 12 Jul 2006 11:44:30 +0100
xsl sort blank to bottom
> But this is illegal syntax, as xsl:sort cannot be a child of xsl:if. It 
> doesn't trigger an error either, by the way.
It should generate an error.

      <xsl:sort select="($name = 'generic' and position()) or 
twz:cell[1]" order="ascending" />

close but not quite;-) That is a boolean valued expression so you are
sorting the key values "true" and "false" which isn't what you want,
what you want is;

  <xsl:sort select="twz:cell[not($name = 'generic')][1]"/>

If $name = 'generic' then this selects the empty node set for each item,
so no sorting is done (or at least its sorted with an empty sort key,
which eis effectively the same thing) and if $name is not 'generic' it
selects the first cell child, and so that is used as the sort key.

  In addition, 
  I would like to ask how to extend the solution above to order the list 
  in such a way that all is ordered except items that have the value 
 "None" or "All". These should end up on the bottom of the list.

 
  <xsl:sort select="twz:cell[not($name = 'generic')][1][.='None', or .='All']"/>
  <xsl:sort select="twz:cell[not($name = 'generic')][1]"/>

the major sort key will have sort key  of "", "All" or "None" sorted in
that order, then the second  sort key will arrange the ones with "".

David

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.