You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2002/02/15 10:04:07 UTC

DO NOT REPLY [Bug 6482] New: - Line Feed in CDATA section causes all CDATA sections to be concatenated when loading into DOM

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: xerces-j-dev@xml.apache.org
        ReportedBy: gplante@spescom.com


<?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: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org