XMLReader problem

classic Classic list List threaded Threaded
1 message Options
hcr
Reply | Threaded
Open this post in threaded view
|

XMLReader problem

hcr
Hi,
    In OPS, I want to process a Document using XMLReader. But CDATA is lose. For example:

    public static void main(String[] args) throws SAXException, IOException{
        Document outData = DocumentHelper.createDocument();
        Element root = outData.addElement("root");
        root.addElement("script").addCDATA("HELLO");
        root.addElement("head").addText(" world");

        SAXStore store = new SAXStore();
        final XMLReader xmlReader = XMLUtils.newSAXParser().getXMLReader();
        xmlReader.setContentHandler(store);
        xmlReader.parse(new DocumentSource(outData).getInputSource());
        System.o ut.println(Dom4jUtils.domToString(store.getDocument()));
    }

The output is that:
<root>
    <script>HELLO</script>
    <head>world</head>
</root>

I want to output:
<root>
    <script><![CDATA[HELLO]]></script>
    <head>world</head>
</root>
       






--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws