Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6318792

Parsing of XML documents containing CDATA section broken in mustang b49

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • xml

      Compile and run following

      ---%<---
      package mustangtest;
      import java.io.StringReader;
      import javax.xml.parsers.DocumentBuilder;
      import javax.xml.parsers.DocumentBuilderFactory;
      import org.xml.sax.InputSource;

      public class CDataTest {
          
          private static final String TEST = "<?xml version=\"1.0\"?>\n"+
                  "<value>\n"+
                  "<![CDATA[//IfStatement/Statement/Block[count(*) = 0]]]>\n"+
                  "</value>\n";
          
          /** Creates a new instance of CDataTest */
          public CDataTest() {
          }
          
          public static void main(String [] args) {
              System.out.println("Java version "+System.getProperty("java.version"));
              DocumentBuilder db;
              try {
                  db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                  db.parse(new InputSource(new StringReader(TEST)));
                  System.out.println("parsed.");
              } catch (Exception ex) {
                  ex.printStackTrace();
              }
          }
          
      }
      ---%<---

      Under JDK 1.5.0 and most of mustang builds it works. With JDK1.6-b49 it produces:

      ---%<---
      Java version 1.6.0-ea
      [Fatal Error] :4:10: XML document structures must start and end within the same entity.
      org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.
              at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:280)
              at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292)
              at mustangtest.CDataTest.main(CDataTest.java:23)
      ---%<---

      The problem is the end of CDATA section. If the last character is not left angle bracket it passes but ']]]>' sequence is not recognized as a bracket and end of CDATA.

            sreddysunw Sunitha Reddy (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: