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

Illegal method behavior for parameters well-formed,check-character-normalization

    XMLWordPrintable

Details

    • b30
    • generic
    • generic
    • Verified

    Description

      Name: eaR10174 Date: 09/15/2003


        The method DOMConfiguration.getParameter() returns false as the default value in case of
      the parameter 'well-formed' and throws DOMException with the FEATURE_NOT_FOUND error code
      in case of the parameter 'check-character-normalization' (see test.java below). According
      to DOMConfiguration javadoc
        
          The following list of parameters defined in the DOM:
          
           ...
           
           "check-character-normalization"

          true
              [optional] Check if the characters in the document are fully normalized according
              to the rules defined in [CharModel] supplemented by the definitions of relevant
              constructs from Section 2.13 of [XML 1.1].
          false
              [required] (default)Do not check if characters are normalized.
              
              
          "well-formed"

          true
              [required] (default) Check if all nodes are XML well formed according to the XML
               version in use in Document.xmlVersion:

                  * check if the attribute Node.nodeName contains invalid characters according
                   to its node type and generate a DOMError of type
                    "wf-invalid-character-in-node-name" if necessary;
                  * check if the text content inside Attr, Element, Comment, Text, CDATASection
                   nodes for invalid characters and generate a DOMError of type
                    "wf-invalid-character" if necessary;
                  * check if the data inside ProcessingInstruction nodes for invalid characters
                   and generate a DOMError of type "wf-invalid-character" if necessary;

          false
              [optional] Do not check for XML well-formedness.


      the method should return true in case of the parameter 'well-formed' and false in case of
      the parameter 'check-character-normalization'.

        The bug appears in jdk1.5.0beta-b18 and affects a new JCK1.5 test:
        
          api/org_w3c/dom/DOMConfiguration/index.html#DOMConfiguration[GetParameter002]


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

      public class test {

          public static void main(String argv[]) {
              new test().run();
          }
          
          public void run() {
              try {
                  DOMImplementation domImpl = DocumentBuilderFactory.newInstance()
                                              .newDocumentBuilder()
                                              .getDOMImplementation();
                  
                  Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);
                  
                  DOMConfiguration config = doc.getConfig();
                  
                  try {
                      Boolean value = (Boolean)config.getParameter("well-formed");
                      
                      if (!value.equals(Boolean.TRUE)) {
                          System.out.println(
                          "Parameter 'well-formed'. Expected: true; Returned: false.");
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
                  
                  System.out.println("");

                  try {
                      Boolean value =
                          (Boolean)config.getParameter("check-character-normalization");
                      
                      if (!value.equals(Boolean.FALSE)) {
                          System.out.println("Expected: true; Returned: false.");
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              } 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-b18)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b18, mixed mode)

      Parameter 'well-formed'. Expected: true; Returned: false.

      org.w3c.dom.DOMException: FEATURE_NOT_FOUND: The parameter check-character-normalization
      is not recognized.
              at
      com.sun.org.apache.xerces.internal.dom.DOMConfigurationImpl.getParameter(DOMConfigurationI
      mpl.java:854)
              at test.run(test.java:34)
              at test.main(test.java:10)
      --------------------------------------------------------------------------

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

      Attachments

        Activity

          People

            nbajajsunw Neeraj Bajaj (Inactive)
            evgsunw Evg Evg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: