xsl-list
[Top] [All Lists]

Re: [xsl] Reordering elements

2006-06-14 05:09:02
I assume, your XML is something like this:

<Root>
      <Story>
        xxx
      </Story>
      <Source>
        yyy
      </Source>
</Root>

I think a stylesheet like this should work:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<!-- identity template; copies everything -->
<xsl:template match="node() | @*">
 <xsl:copy>
   <xsl:apply-templates select="node() | @*" />
 </xsl:copy>
</xsl:template>

<xsl:template match="Story">
 <xsl:copy>
   <xsl:copy-of select="@*" />
   <xsl:apply-templates />
   <xsl:copy-of select="following-sibling::Source/node()" />
 </xsl:copy>
</xsl:template>

<xsl:template match="Source" />

</xsl:stylesheet>

In this stylesheet, the identity template has been modified for the
conditions you have specified.

Regards,
Mukul

On 6/14/06, Chad Chelius <cchelius(_at_)agitraining(_dot_)com> wrote:

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>?

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>