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: xsl:sort/@case-order feature missed


> we are missing a neutral value for the
> xsl:sort/@case-order. We are using a 
> 
> <xsl:sort ... case-order='{$which-order}'>
> 
> within a parametrized template and would like
> to have all three cases for which-order:
> 
> 1. lower-first
> 2. upper-first
> 3. no-particular-ordering-on-upper-and-lower
> 
> Since we are using xsl:variables we cannot simply
> leave the case-order attribute away.

Suggestion : have two <xsl:sort> elements for the same
key, but only "enable" one of the two depending on the
presence of a case order :

<xsl:variable
    name="has-order"
    select="$which-order='lower-first' or $which-order='upper-first'" />
<xsl:variable name="used-order">
    <xsl:choose>
        <xsl:when test="$has-order">
            <xsl:value-of select="$which-order" />
        </xsl:when>
    </xsl:choose>
    <xsl:otherwise>upper-first</xsl:otherwise>
</xsl:variable>
...
<xsl:sort
    select="...[$has-order]"
    case-order="{$used-order}">
<xsl:sort
    select="...[not($has-order]">

I think this will correctly handle any value of $which-order that isn't
a recognized case-order. You can get rid of $has-order if you say that
$which-order should be false() or the empty node-set when 
a case-neutral sort is desired.

Finally, I haven't checked the spec but Mike May's book says that
case-order's value when not specified is language-dependant.
I understand this to mean that case-order always has a value,
so if you are sorting the following sequence :

<elt val="A" />
<elt val="a" />
<elt val="A" />

and you don't specify a case-order, it will sort as either A,A,a
or a,A,A depending on the language; but not the document
order A,a,A as you seem to imply by
"no-particular-ordering-on-upper-and-lower"

I haven't tested this though so I may be totally wrong, or
it might be implementation-dependant.

Hope this helps.
--Jonathan



 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]