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

Re: Attribute-based XML Sorting using XSL

Subject: Re: Attribute-based XML Sorting using XSL
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Mon, 17 Jun 2002 17:07:49 -0700
xml sorting
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 17 June 2002 12:41, Matt Jones wrote:
>           <xsl:apply-templates select="ROW">
>                 <xsl:sort select="COLUMN[@value]"/>
>           </xsl:apply-templates>

What you are saying here is, "Sort using all COLUMN children that have a 
'value' attribute."  This doesn't take into account the value of @value, so 
the sorting is effectively useless.

As you might have guessed, the <xsl:sort/> here is where you need to specify 
on which column to sort.  What you really wanted to say is, "Sort using the 
COLUMN for which @name is equal to the user's desired column, and sort using 
the value of @value from that COLUMN".

This is pretty simple to do:

<xsl:sort select="COLUMN[@name = $the-column-name]/@value"/>

A previous responder posted a similar solution, but forgot the '/@value'.  
Without the '/@value', the sort will proceed using the text value of the 
<COLUMN/> element, which is empty and obviously not what you want.

- -- 
Peter Davis
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9DnnVNSZCJx7tYycRAhuNAKC22QRyHhK/zh2YTyV+98lz+68xLACgoOQY
sc5vHA7BB5W42gdoYHLxF2w=
=Ejlz
-----END PGP SIGNATURE-----


 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.