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

Re: Sorting outside of a for-each

Subject: Re: Sorting outside of a for-each
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Fri, 12 Oct 2001 15:23:39 -0400
unique country names
In addition to Jeni's suggestion, you could create a node-set of the unique
country names using the "Muenchian" method (look it up in one of the FAQs),
then do a for-each over the unique names.  Within each for-each interation,
use for-each or apply-templates selecting template matching the country that
is currently active:

<xsl:variable name='current-country' select='@country_id/>
<xsl:apply-templates
select='/root/country_name[@country_id=$current-country]'/>

(assumes that the document element is called "root").  I didn't test this
but it should be pretty close to what you need.

Cheers,

Tom P

[Steve Bruce]

>
> The XML I am using to create a HTML page is not generated in a sorted
order.
>   Below is a subset of the XML I am using.
>
> <country_name country_id="US">United States</country_name>
> <country_name country_id="US">United States Dollar</country_name>
> <country_name country_id="GB">United Kingdom Pound</country_name>
> <country_name country_id="GB">United Kingdom</country_name>
> <country_name country_id="FR">France Francs</country_name>
> <country_name country_id="FR">France</country_name>
> <country_name country_id="DE">Germany</country_name>
> <country_name country_id="DE">Germany Marks</country_name>
>
> <country_sort country_sort_id="US">
> <country_sort country_sort_id="GB">
> <country_sort country_sort_id="FR">
> <country_sort country_sort_id="DE">
>
> The country_name tags are not returned in a sorted order.  I want to loop
by
> the country_sort tags, because they only show 1 instance of the items in
the
> country_name tags.  If I looped by the country_name, I would duplicate my
> results.  For my output, I want to return the country_name for the
> country_sort_id that excludes the currency (dollar, pounds, francs,
marks).
> So, what I believe I want to do is a for-each on the country_sort tag and
> then return the first country_name field for that id, assuming the
> country_name tags have been sorted in ascending order.  This would then
> ensure the name with the currency is always second.
>
> However, I have not been able to determine a process for sorting the
> country_name tag without a corresponding for-each.  Is this possible?



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.