DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6482>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6482

Line Feed in CDATA section causes all CDATA sections to be concatenated when loading 
into DOM

           Summary: Line Feed in CDATA section causes all CDATA sections to
                    be concatenated when loading into DOM
           Product: Xerces2-J
           Version: 2.0.0
          Platform: PC
        OS/Version: MacOS X
            Status: NEW
          Severity: Major
          Priority: Other
         Component: SAX
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


<?xml version=\"1.0\"?>
<a>
  <b><![CDATA[cdata-test1;]]></b>
  <c><![CDATA[cdata-test2;\n]]></c>
</a>

When the above XML is loaded into a DOM, then the second CDATA section contains 
both CDATA sections' data. The printed output of the loaded DOM is shown below:

<?xml version="1.0"?>
<a>   <b><![CDATA[cdata-test1;]]></b>   <c><![CDATA[cdata-test1;cdata-test2;
]]></c> </a>

If the line feed ("\n") is removed, then the problem does not occur.

The sample code used is as follows:

    public void simpleTest(){

        String cdataXML =
            "<?xml version=\"1.0\"?>\n"+
            "<a>\n"+
            "  <b><![CDATA[cdata-test1;]]></b>\n"+
            "  <c><![CDATA[cdata-test2;\n]]></c>\n"+
            "</a>\n";


        try{
            DOMParser       parser = new DOMParser();
            XMLSerializer   serial = new XMLSerializer();

            parser.parse(new InputSource(new java.io.StringReader(cdataXML)));

            serial.setOutputCharStream(new java.io.PrintWriter(System.out));
            serial.asDOMSerializer().serialize(parser.getDocument());

        }catch(Exception ex){
            ex.printStackTrace();
        }
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to