copy the result of apply-templates : apply templates « XSLT stylesheet « XML






copy the result of apply-templates


File: Data.xml
<colors>
  <color>
    red:
    <shade>A</shade>
    <shade>B</shade>
    <shade>C</shade>
  </color>
  <color>yellow</color>
  <color>
    blue:
    <shade>F</shade>
    <shade>G</shade>
    <shade>H</shade>
  </color>
</colors>


File: Transform.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

Output:

<colors>
    <color>
    red:
    <shade>A</shade>
        <shade>B</shade>
        <shade>C</shade>
    </color>
    <color>yellow</color>
    <color>
    blue:
    <shade>F</shade>
        <shade>G</shade>
        <shade>H</shade>
    </color>
</colors>

 








Related examples in the same category

1.apply template
2.apply-templates with mode=toc
3.Apply template, select from a list
4.apply-templates select="tag name"