Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - XSLT question >Thread Next - Re: XSLT question Re: XSLT questionTo: NULL Date: 5/1/2008 1:12:00 PM
time2fly@g... wrote:
> I want to transform the XML so that the result is the same except one
> of the c nodes is always returned first in the response based on a
> specfic id element (see below).
Pass in the id of the 'c' element as a parameter and then use the
identity transformation template plus a template for 'b' elements that
ensures that the 'c' children are processed in the order you want:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="id" select="3"/>
<xsl:strip-space elements="*"/>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="b">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="c[@id = $id]"/>
<xsl:apply-templates select="c[not(@id = $id)]"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
