xsl-list
[Top] [All Lists]

Re: [xsl] Multiple Sort Key Components

2019-06-05 06:59:28
Thank you, Michael. 

Sent from Yahoo Mail on Android 
 
  On Wed, Jun 5, 2019 at 3:27 AM, Michael Kay 
mike(_at_)saxonica(_dot_)com<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>
 wrote:   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 KaySaxonica


On 5 Jun 2019, at 00:28, Don Smith dsmith_lockesmith(_at_)yahoo(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 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 order2. 
@start_element value3. @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 archiveEasyUnsubscribe(by email)

XSL-List info and archiveEasyUnsubscribe(by email)  
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>