Great question, oftem people need to reorganize their XML for further processing, and this is a great oportunity to clarify available techniques.
You can achieve what you're asking simply by using xsl:copy and/or copy-of, although I doubt your goal in practice is as simple as the example you've posted in this thread.
So, if you need to restructure the children of your root element and you're confident about the simplicity of the XML you're trying to restructure, then you'd do something like this:
[HTML]<xsl:template match="/ROOT">
<xsl:copy>
<xsl:copy-of select="A1"/>
<xsl:copy-of select="D1"/>
<xsl:copy-of select="B1"/>
<xsl:copy-of select="C1"/>
</xsl:copy>
</xsl:template>[/HTML]
The above code will output what you've asked for. Now, if you have a much larger document, and what you're really after is mooving some of the nodes around while maintaining an abtract hierearchy, you could use the technique in example code below.
[HTML]<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:apply-templates select="self::* " mode="copy"/>
</xsl:template>
<xsl:template match="A1">
<xsl:apply-templates select="self::* " mode="copy"/>
<xsl:apply-templates select="../D1" mode="copy"/>
</xsl:template>
<xsl:template match="B1">
<xsl:apply-templates select="self::* " mode="copy"/>
<xsl:apply-templates select="../C1" mode="copy"/>
</xsl:template>
<xsl:template match="D1"/>
<xsl:template match="C1"/>
<xsl:template match="*" mode="copy">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
</xsl:stylesheet>[/HTML]
In this case you are copying an abstract document structure and repositioning some of the elements in strategic places.
Hope this helps.
This is a great topic so I'll be posting the content on my blog so more people can benefit from this example.
XSLT By Example
Miguel de Melo
=============== =============
XSLT By Example