"Siu" wrote:
> Hi Martin,
> your suggestion is perfect, thank you:)
>
> I've have another little question: I've used the XslTransform class in order
> to sort that xml file into another new xml file, and it works, but the
> problem is that the method or the xslt file writes into the output file as
> first row this:
>
> <?xml version="1.0" encoding="utf-8" ?>
>
> How can I avoid writing this row?
>
> Thank you again
>
> "Martin Honnen" wrote:
>
> >
> >
> > Siu wrote:
> >
> >
> > > my real
> > > XML file is like this:
> > >
> > > - <APPLICATIONLIST>
> > > - <APPLICATION APPNAME="ActiveSync">
> > > - <ICONGROUP SOURCE="ActiveSync.lnk">
> > > - <DEST TARGET="START" />
> > > </ICONGROUP>
> > > </APPLICATION>
> > > - <APPLICATION APPNAME="AutoCAD">
> > > - <ICONGROUP SOURCE="AutoCAD.lnk">
> > > <DEST TARGET="START" />
> > > </ICONGROUP>
> > > </APPLICATION>
> > > - <APPLICATION APPNAME="Banana">
> > > - <ICONGROUP SOURCE="Banana.lnk">
> > > <DEST TARGET="START" />
> > > </ICONGROUP>
> > > </APPLICATION>
> > > - <APPLICATION APPNAME="Bridge Workstation">
> > > </APPLICATION>
> > > <APPLICATIONLIST>
> > >
> > > I would like to order my XML file by APPNAME of each APPLICATION node: the
> > > latter can be also nested into other APPLICATION node, like this:
> > >
> > > - <APPLICATION APPNAME="MicrosoftOffice">
> > > - <ICONGROUP SOURCE="ActiveSync.lnk">
> > > - <DEST TARGET="START" />
> > > </ICONGROUP>
> > > - <APPLICATION APPNAME="Excel"/>
> > > - <APPLICATION APPNAME="Word"/>
> > > - <APPLICATION APPNAME="PowerPoint"/>
> > > </APPLICATION>
> >
> > Here is an XSLT 1.0 stylesheet that sorts that:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet
> > xmlns:xsl="
http://www.w3.org/1999/XSL/Transform" > > version="1.0">
> >
> > <xsl:output method="xml" encoding="UTF-8" indent="yes" />
> >
> > <xsl:template match="@* | node()">
> > <xsl:copy>
> > <xsl:apply-templates select="@* | node()" />
> > </xsl:copy>
> > </xsl:template>
> >
> > <xsl:template match="APPLICATIONLIST">
> > <xsl:copy>
> > <xsl:apply-templates select="APPLICATION">
> > <xsl:sort select="@APPNAME" data-type="text" order="ascending"
> > lang="en" case-order="upper-first" />
> > </xsl:apply-templates>
> > </xsl:copy>
> > </xsl:template>
> >
> > <xsl:template match="APPLICATION">
> > <xsl:copy>
> > <xsl:apply-templates select="@*" />
> > <xsl:apply-templates select="ICONGROUP" />
> > <xsl:apply-templates select="APPLICATION">
> > <xsl:sort select="@APPNAME" data-type="text" order="ascending"
> > lang="en" case-order="upper-first" />
> > </xsl:apply-templates>
> > </xsl:copy>
> > </xsl:template>
> >
> > </xsl:stylesheet>
> >
> > It is easily possible with .NET to apply the transformation to the
> > source input, see the XslTransform class in the .NET documentation.
> >
> > --
> >
> > Martin Honnen
> >
http://JavaScript.FAQTs.com/