CDATA_SECTION_ELEMENTS problem using qualified name 2003-04-09 - By Hess Yvan
Hi,
I have a problem to output XML element as CDATA section using qualified name, but not for element that have "no qualified name". I am using Xalan version 2.5D1 and my xml is as follow:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?> <custom:metadata xmlns:custom="http://www.gogo.com/edoc/metadata/custom/"> <custom:section1>SECTION 1</custom:section1> <custom:section2>SECTION2</custom:section2> <section3>SECTION 3 SANS CDATA</section3> </custom:metadata>
Here is the code for the transformation:
TransformerFactory tFactory = TransformerFactory.newInstance(); SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory); transformerHandler = saxTFactory.newTransformerHandler(); format.put(OutputKeys.METHOD, "xml"); format.put(OutputKeys.ENCODING, "ISO-8859-1"); format.put(OutputKeys.INDENT, "yes"); format.put(OutputKeys.CDATA_SECTION_ELEMENTS,"custom:section1 custom:section2 section3");
transformerHandler.getTransformer().setOutputProperties(format);
StreamResult res = new StreamResult(out); transformerHandler.setResult(res);
As you can seen bellow, the section3 that have no qualified name has been wrapped with a CDATA section, but not the section1 and 2 using qname.
<?xml version="1.0" encoding="ISO-8859-1"?> <custom:metadata xmlns:custom="http://www.gogo.com/edoc/metadata/custom/"> <custom:section1>SECTION 1</custom:section1> <custom:section2>SECTION2</custom:section2> <section3><![CDATA[SECTION 3 SANS CDATA]]></section3> </custom:metadata>
Does anybody have an idea why I get this strange result ?
Thanks for your answer.
Regards. Yvan
|
|