xsl-list
[Top] [All Lists]

Re: [xsl] Sorting a XML file with XSL

2007-10-24 02:28:40
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--