Re: sorting by attribute

Subject: Re: sorting by attribute
From: "Steve Muench" <smuench@xxxxxxxxxxxxx>
Date: Sat, 26 Feb 2000 00:38:23 -0800
How about:

<wrapper xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xsl:version="1.0">
  <xsl:for-each select="sender/a">
    <xsl:sort select="@clli"/>
    <a><xsl:value-of select="@clli"/></a>
    <b><xsl:value-of select="@b"/></b>
  </xsl:for-each>
</wrapper>
  
This produces:

<wrapper><a>100</a><b>10</b><a>200</a><b>20</b></wrapper>

for your source document.

__________________________________________________________
Steve Muench, Lead XML Evangelist / Consulting Product Mgr
Oracle Corp, Business Components for Java Development Team
http://technet.oracle.com/tech/xml
----- Original Message ----- 
From: "Dave Pawson" <dave.pawson@xxxxxxxxxx>
To: "xsl list" <xsl-list@xxxxxxxxxxxxxxxx>
Sent: Friday, February 25, 2000 11:56 PM
Subject: sorting by attribute


| Can XSLT sort by attribute value?
| 
| <sender> 
| <a clli="200" b="20"/> 
| <a clli="100" b="10"/> 
| 
|       </sender> 
| 
| Output needed is
| <wrapper>
|   <a> @clli</a>
|   <b> @b </b>
| </wrapper>
| 
| I can sort by element content. 
| REC says
| 
| <xsl:sort
|   select = string-expression 
|   
| So, @clli is a string expression.
| 
| If I do a for-each on a/@clli
| I can't get to the siblings, (no parent)
| element a has no content so I can't sort on that.
| 
| I'm totally stuck on this one.
| Can anyone help please.
| 
| Regards, DaveP
| 
| 
| 
| 
|  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| 


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


Current Thread