Reputation: 13
I've some problems by transforming my xml. I'ld like to hive-off child-node in correct order.
<span style="font-family: [Ohne];">
<span style="font-family: qwe;">etu</span>
<!-- hive off this nested child-node above the parent -->
restia volorsin
</span>
<!-- after xslt -->
<span style="font-family: [Ohne];">restia volorsin</span>
<span style="font-family: qwe;">etu</span>
see more example code
Could anyone gave me some tips?
Upvotes: 1
Views: 165
Reputation: 243549
As easy as this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="span[span]">
<xsl:copy>
<xsl:copy-of select="@*|node()[not(self::span)]"/>
</xsl:copy>
<xsl:copy-of select="span"/>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the provided XML document:
<span style="font-family: [Ohne];">
<span style="font-family: qwe;">etu</span>
<!-- hive off this nested child-node above the parent -->
restia volorsin
</span>
the wanted, correct result is produced:
<span style="font-family: [Ohne];"><!-- hive off this nested child-node above the parent -->
restia volorsin
</span>
<span style="font-family: qwe;">etu</span>
Upvotes: 1