|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Moving an element to a new location in the Result
> I want to move the former "b1" elements down the tree and re-name them
> (all) along the way, yet maintain the actual data they contain ("XYZ1",
> etc.). The main thing is to move them down there, not re-name them.
Remember that you are not "moving" anything -- you're creating a whole new
result tree. That may seem to be a trivial detail, but it's really a
fundamental concept you need to remember always.
If the whitespace-only text nodes are not significant, then the following
stylesheet will do what I think you want:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="b1">
<new_b1>
<xsl:apply-templates select="@* | node()"/>
</new_b1>
</xsl:template>
<xsl:template match="document1">
<document222>
<xsl:apply-templates select="*[not(self::b1)]"/>
<xsl:apply-templates select="b1"/>
</document222>
</xsl:template>
</xsl:stylesheet>
If you really need to preserve whitespace-only text nodes, things get a
bit trickier.
Dave
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








