2
votes

I need to transform all nodes from

<?xml version="1.0" encoding="UTF-8"?><root>
<catalog>
    <cd>
    <country> &lt;li&gt;WIN8&lt;/li&gt;&lt;li&gt;Mac&lt;/li&gt;&lt;li&gt;OS&lt;/li&gt;</country>
    <name> &lt;li&gt;WIN8&lt;/li&gt;&lt;li&gt;Mac&lt;/li&gt;&lt;li&gt;OS&lt;/li&gt;</name>
    </cd>
</catalog>
</root>

into

    <?xml version="1.0" encoding="UTF-8"?>
<root>
    <catalog>
        <cd>
        <country><![CDATA[ <li>WIN8</li><li>Mac</li><li>OS</li>]]></country>
        <name><![CDATA[ <li>WIN8</li><li>Mac</li><li>OS</li>]]></name>
        </cd>
    </catalog>
</root>

I know that I can apply xsl using cdata-section-elements="country name", but Is there a way to select all nodes in cdata-section-elements? can use http://xsltransform.net/ to transform. here is the xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output cdata-section-elements="country name"/>
  <xsl:template match="node() | @*">
    <xsl:copy>
      <xsl:apply-templates select="node() | @*" />
    </xsl:copy>
  </xsl:template>    
</xsl:stylesheet>

thanks

1

1 Answers

4
votes

The documentation http://www.w3.org/TR/xslt20/#serialization says clearly that "The cdata-section-elements attribute is a whitespace-separated list of QNames.". So you will need to list the element names whose contents you want to be serialized as CDATA sections. There is no wild card like with for instance strip-space.