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

Re: Multiple Sort Key Components

Subject: Re: Multiple Sort Key Components
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 5 Jun 2019 08:27:07 -0000
Re:  Multiple Sort Key Components
Your first sort key is position(). Every item in the input has a different
value for position(). The Nth sort key only affects the outcome if all sort
keys before the Nth have duplicate values. When there are no duplicates for
the first sort key, the second and third will therefore have no effect.

Michael Kay
Saxonica

> On 5 Jun 2019, at 00:28, Don Smith dsmith_lockesmith@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello,
>
> I'm attempting to sort the content of a variable using multiple sort key
components and my last component (@range_length) doesn't take effect. Given
this input which reflects paragraphs in document order:
>
>  <list_of_group_ranges>
>                         <range comment_id="2"
>                                start_element="d34e70"
>                                end_element="d34e141"
>                                range_length="10"/>
>                         <range comment_id="3"
>                                start_element="d34e70"
>                                end_element="d34e160"
>                                range_length="14"/>
>                         <range comment_id="4"
>                                start_element="d34e70"
>                                end_element="d34e102"
>                                range_length="5"/>
>                         <range comment_id="17"
>                                start_element="d34e174"
>                                end_element="d34e214"
>                                range_length="26"/>
>                         <range comment_id="18"
>                                start_element="d34e174"
>                                end_element="d34e193"
>                                range_length="22"/>
>                         <range comment_id="23"
>                                start_element="d34e203"
>                                end_element="d34e209"
>                                range_length="25"/>
> </list_of_group_ranges>
>
> I want to sort these according to 3 sort components:
> 1. document order
> 2. @start_element value
> 3. @range_length value
>
> The code I'm using to sort is:
>
>                        <xsl:for-each select="$list_of_group_ranges/*">
>                             <xsl:sort select="position()"/>
>                             <xsl:sort select="@start_element"/>
>                             <xsl:sort data-type="number" order="descending"
select="@range_length"></xsl:sort>
>                             <xsl:copy-of select="."/>
>                         </xsl:for-each>
>
> But the last sort component, @range_length, isn't taking effect as the
<range> elements with the same @start_element don't sort according to
@range_length. What am I missing?
>
> Thanks
>
> Don
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by
email <>)

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.