Login  Register

Re: XMLReader problem

Posted by Alessandro Vernet on Jan 20, 2010; 3:11am
URL: https://discuss.orbeon.com/XMLReader-problem-tp1018098p1018122.html

Yes, this is because this information is part of the SAX LexicalHandler, which we don't support. But note that the CDATA markers are just syntactic sugar, and a document without them should be considered equivalent.

(BTW, I am not sure what happened, but I got your message 8 times through the mailing list.)

Alex



On Jan 19, 2010, at 5:57 PM, hechengrong <[hidden email]> wrote:

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: [hidden email]
For general help: [hidden email]
OW2 mailing lists service home page: http://www.ow2.org/wws


--
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
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet