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

Re: Sorting a XML file with XSL

Subject: Re: Sorting a XML file with XSL
From: Buddhi Dananjaya <buddhi@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 24 Oct 2007 15:52:14 +0530
Re:  Sorting a XML file with XSL
Finally I got the thing working;
removed 'data/' from sort element.. see Following XSL...

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Identity transform -->
<xsl:template match="node()">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>


   <xsl:template match="root">
      <xsl:copy>
         <xsl:copy-of select="@*"/>
         <xsl:apply-templates select="*">
            <xsl:sort select="comment"/>
            <xsl:sort select="@name"/>
         </xsl:apply-templates>
      </xsl:copy>
   </xsl:template>
</xsl:stylesheet>

Abel Braaksma wrote:
Buddhi Dananjaya wrote:
I tried with the XSL posted. But after transformation I am again getting same XML as out put (not sorted)

Why it is mentioned as comment blocks are not uniques, as I feel they are unique.. Main.cs, Text.cs, etc.

Not to be offensive, but what you "feel" to be unique is something a computer program usually doesn't understand. In most computer terminologies, the "unique" property of a column/field means that every row contains an entry different from any other. You have "Main.cs" 8 times and "Text.cs" 5 times, meaning: not unique.


But that's hardly a problem: if you sort a non-unique element, all equal elements will be put together in the output.

If it doesn't sort for you, you probably have a mismatch in the template. If the name is not correct, it will never be found and the sort will never be hit. Please show what you got this far (an exact, complete and working stylesheet, including headers) and the source (also: be exact, include any namespaces etc). Make sure, before you post, that the code you post acts the way you say it does (just make a small test set, run it, then post it). Then we'll likely to quickly spot where the problem lies.

Cheers,
-- Abel Braaksma

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.