[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:01:38 +0530
Re:  Sorting a XML file with XSL
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.


Florent Georges wrote:
Buddhi Dananjaya wrote:

Hi

Following is my sample XML file, I want to sort this base on
<comment> tag and make a new XML file using a style sheet

You can use the Modified Identity pattern:


<xsl:output indent="yes"/>

    <!-- 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="data/comment"/>
          </xsl:apply-templates>
       </xsl:copy>
    </xsl:template>

  The data/comment contents are not unique.  If you want to order a
second field to perform more precise sorting, you can do so using a
second xsl:sort instruction.  For instance, if you want to sort on
comment then on @name:

    <xsl:apply-templates select="*">
       <xsl:sort select="data/comment"/>
       <xsl:sort select="data/@name"/>
    </xsl:apply-templates>

Regards,

--drkm
























_____________________________________________________________________________ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail

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.