xsl-list
[Top] [All Lists]

Re: [xsl] Conditional xsl:sort and leaving some items out of sorting

2006-07-12 03:45:07

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>