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

sorting and preceding-sibling - only print *first* in

Subject: sorting and preceding-sibling - only print *first* in sorted list??
From: "Hardy Merrill" <HMerrill@xxxxxxxxxxxxxxxx>
Date: Tue, 12 Oct 2004 09:55:29 -0400
xsl sort preceding sibling
I know this topic has been covered ad-nauseum, but even after reading
the faq and googling, I can't quite "get" what I need to do to make this
work.

Here is a sample xml doc:

<legislators>
    <legislator>
        <legislator_id>1</legislator_id> 
        <legislator_active>1</legislator_active> 
        <legislator_active_date>20020101000000</legislator_active_date>

        <district_id>046</district_id> 
        <district_type>A</district_type> 
        <district_no>001</district_no>  
        <full_name>Doe, John J.</full_name> 
    </legislator>
    <legislator>
        <legislator_id>21</legislator_id> 
        <legislator_active>0</legislator_active> 
        <legislator_active_date>19960101000000</legislator_active_date>

        <district_id>046</district_id> 
        <district_type>A</district_type> 
        <district_no>001</district_no>  
        <full_name>Smith, Jane</full_name> 
    </legislator>
    <legislator>
        <legislator_id>95</legislator_id> 
        <legislator_active>1</legislator_active> 
        <legislator_active_date>20020101000000</legislator_active_date>

        <district_id>034</district_id> 
        <district_type>A</district_type> 
        <district_no>002</district_no>  
        <full_name>Jones, Daniel</full_name> 
    </legislator>
</legislators>

I want my xsl style sheet to produce html with the records in this
order:

District    Legislator
----------   ---------------
001 A       Doe, John J.
001 A       Smith, Jane
002 A       Jones, Daniel

Notice that legislators for the same district are listed together. 
What I
can't seem to figure out is how to ONLY print the district info for the
*first* district in the sorted list.  So I *want* that listing to look
like this:

District    Legislator
----------   ---------------
001 A       Doe, John J.
                  Smith, Jane
002 A       Jones, Daniel

Currently I have this for-each loop and sort's:

<xsl:for-each select="$section_legislators">
      <xsl:sort select="district_type" />
      <xsl:sort select="district_no" data-type="number" />
      <xsl:sort select="legislator_active_date" 
                      data-type="number"
                      order="descending" />

I was trying to use "preceding-sibling" to figure out if the previous
sibling ***in sorted order*** had the same district, but I've now
figured out after reading on the subject that "preceding-sibling" does
not operate on the sorted tree - instead it operates on the original
tree that is in "document" order.

I'd like to use the best/most efficient method to solve this problem -
the muncheon technique using keys if possible.  Can I do that, and if
so, how?

TIA.

Hardy Merrill
New York State Division of Housing & Community Renewal

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.