[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
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|