[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Reordering elements


Subject: RE: [xsl] Reordering elements
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 13 Jun 2006 22:30:35 +0100

<xsl:template match="*">
  <xsl:copy>
    <xsl:apply-templates/>
  </xsl:copy>
</xsl:template>

<xsl:template match="Root">
  <xsl:copy>
    <xsl:apply-templates select="*[not(self::Source)]"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="Story">
  <xsl:copy>
    <xsl:apply-templates select="following-sibling::Source"/>
    <xsl:apply-templates select="*"/>
  </xsl:copy>
</xsl:template>

Michael Kay
http://www.saxonica.com/


> -----Original Message-----
> From: Chad Chelius [mailto:cchelius@xxxxxxxxxxxxxxx] 
> Sent: 13 June 2006 20:41
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Reordering elements
> 
> 
> In a situation where my XML file looks like this:
> 
> <Root>
> 	<Story>
> 	<Source>
> </Root>
> 
> How would I move the <Source> element so that and it's 
> children are now a child of <Story>?


Current Thread
Keywords
xml