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

RE: xsl:sort

Subject: RE: xsl:sort
From: April Fleming <AFleming@xxxxxxxxxxxx>
Date: Mon, 21 Jun 2004 16:47:31 -0400
april fleming
What a jerk I am...

The problem was not the attribute itself, when I changed my code to this:

 <xsl:sort select="@*[name()=$orderBy]"/>

It worked for all of the attributes.

April 


-----Original Message-----
From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx] 
Sent: Monday, June 21, 2004 4:24 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  xsl:sort 


At 2004-06-21 15:15 -0400, April Fleming wrote:
>Sorry,

No apology necessary ... just trying to figure out what was happening when 
you said it "does not work".

>When I say it does not work, I mean it does not sort by that attribute. 
>When the order by value is an attribute that exists in every row (ie. 
>Ip,
>device_name) then the results are sorted by that attribute, however, if the
>order by value is "device_os" which does not exist in every row, the data
>comes back unsorted.

Would you agree that the data comes back in document order for those nodes 
where the attribute is absent?

>I would like for it to treat the nonexistent attributes
>as attribute="", as you say that the standard defines, unfortunately 
>that is not what it is doing.

Such nodes will sort before attributes with string values, and in the group 
of the nodes where the attribute is absent they will be handled in document 
order.

Wait ... I just looked at your original post again, and it looks like I 
missed something in the haste of my earlier response:

At 2004-06-21 14:50 -0400, April Fleming wrote:
><xsl:template match="rs:data">
>  <xsl:comment>Loop over the rows in the recordset</xsl:comment>
>  <xsl:for-each select="z:row">
>             <xsl:sort select="z:row/@*[name()=$orderBy]"/>

You seem to be selecting the rows to be sorted, and then sorting them by a 
non-existent node.  Note how your select is referencing a child z:row of 
the z:row node being selected ... yet looking at your data, the z:row is an 
empty element ... perhaps you missed that the sort expression evaluation is 
done based on the node being sorted and not the current node when the 
selection was made.

I recommend you try select="@*[name()=$orderBy]" to see if you then get the 
desired results ... though your original code should not have worked even 
for nodes where the attribute is present, so I'm surprised you haven't 
always had problems with this code fragment.

I hope this helps.

.......................... Ken

--
Public training 3 days XSLT & 2 days XSL-FO: Phoenix,AZ 2004-08-23
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--


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.