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

Warning about splitting CDATA section is not reported

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b30
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        Name: eaR10174 Date: 09/02/2003


          The DOMErrorHandler handler is not called in case when CDATA section containing the
        termination marker ']]>' is splitted (see test.java below). According to the
        DOMConfiguration javadoc
          
            "split-cdata-sections"

            true
                [required] (default)Split CDATA sections containing the CDATA section termination
                marker ']]>'. When a CDATA section is split a warning is issued with a
                DOMError.type equals to "cdata-sections-splitted" and DOMError.relatedData equals
                to the first CDATASection node in document order resulting from the split.

        a warning should be reported.

          The bug appears in jdk1.5.0beta-b17 and affects new JCK1.5 tests:
          
            api/org_w3c/dom/DOMLocator/index.html#DOMLocator[Get001]
            api/org_w3c/dom/DOMError/index.html#DOMError

        ------------------------------------test.java-----------------------------
        import javax.xml.parsers.DocumentBuilderFactory;
        import javax.xml.parsers.DocumentBuilder;
        import org.w3c.dom.Document;
        import org.w3c.dom.CDATASection;
        import org.w3c.dom.DOMConfiguration;
        import org.w3c.dom.DOMError;
        import org.w3c.dom.DOMErrorHandler;

        public class test {
              
            DocumentBuilder docBuilder = null;

            public static void main(String argv[]) {
                new test().run();
            }
            
            public void run() {
                try {
                    DocumentBuilderFactory docBF = DocumentBuilderFactory.newInstance();
                    docBuilder = docBF.newDocumentBuilder();
                    
                    Document doc = docBuilder.getDOMImplementation()
                                   .createDocument("namespaceURI", "ns:root", null);;
                    
                    CDATASection cdata = doc.createCDATASection("text1]]>text2");
                    doc.getDocumentElement().appendChild(cdata);
                    
                    DOMConfiguration config = doc.getConfig();
                    DOMErrorHandler erroHandler = new DOMErrorHandler() {
                        public boolean handleError(DOMError error) {
                            System.out.println(error);
                            return true;
                        }
                    };
                    config.setParameter("error-handler", erroHandler);
                    
                    doc.normalizeDocument();
                } catch (Exception e) {
                    e.printStackTrace();
                    return;
                }

            }
        }
        --------------------------------------------------------------------------
        % java -showversion test
        java version "1.5.0-beta"
        Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b17)
        Java HotSpot(TM) Client VM (build 1.5.0-beta-b17, mixed mode)

        --------------------------------------------------------------------------

        ======================================================================

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                kkawagucsunw Kohsuke Kawaguchi (Inactive)
                Reporter:
                evgsunw Evg Evg (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: