Well, if I use this stylesheet:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="node/text()"> <xsl:copy/> </xsl:template> </xsl:stylesheet>
in this xml file:
<?xml version="1.0" encoding="utf-8"?> <node id=1 text="Book Information" ><![CDATA[This is sample text]]></node>
I get a parsing error because id=1 is invalid XML.
Putting quotes around the attribute value ( id="1" ) and repeating the stylesheet, I get the output:
This is a sample text.
So, let's begin. Basically, just treat CDATA as node text and you're on your way.
You said:
I found something like:
<xsl:output cdata-section-elements="text"/>
and then pick up CDATA:
<xsl:value-of select="node" />
This approach works very well if you use value-of . There will be an example according to your comments, use value-of instead. Note, however, that cdata-section-elements only works on the output side, indicating which output XML elements you want to print as CDATA sections instead of the usual old character data. This has nothing to do with data mining.
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output cdata-section-elements="foo"/> <xsl:template match="/"> <foo> <xsl:value-of select="node"/> </foo> </xsl:template> </xsl:stylesheet>
displays
<?xml version="1.0"?> <foo><![CDATA[This is sample text]]></foo>
Owen S.
source share