[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: Florent Georges <lists@xxxxxxxxxxxx>
Date: Wed, 24 Oct 2007 10:47:45 +0200 (CEST)
Re:  Sorting a XML file with XSL
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.