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

Re: sort problem

Subject: Re: sort problem
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Wed, 4 Sep 2002 22:11:55 -0700
Re:  sort problem
On Wednesday 04 September 2002 21:28, aruniima.chakrabarti@xxxxxxxxxxxxxxxxxx 
>  Thanks David... but i still confused...if i do <xsl:apply-templates
> select="@* | * | text()"> or <xsl:apply-templates select="@* | * |
> node()">, the output doesnot contain any of the attributes. Please help in
> getting the required output.

The problem is probably that if you output attributes, they must be output 
immediately after the element to which they belong (you can't output any 
other elements or text before your attributes).

Since you are sorting by the name() of the nodes, the text() nodes will always 
be output first, since the name of a text node is "#text".  The hash mark (#) 
will be sorted alphabetically before the names of your attributes.

The solution could be to apply-templates to attributes and other nodes 
separately.  It doesn't make any sense to sort the output of attributes 
anyway (since attributes don't have any defined order).

<xsl:template match="/ | @* | node()">
    <xsl:apply-templates select="@*"/>
    <xsl:apply-templates select="node()">
      <xsl:sort select="name()"/>

Let me know if this solves your problem, and HTH.

Peter Davis

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

Current Thread


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.
First Name
Last Name
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.