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

Document.createElement() doesn't accept ":",":xxx" and "xxx:" as element names

    XMLWordPrintable

    Details

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

      Description



      Name: eaR10174 Date: 03/06/2001



        The implementation of method org.w3c.dom.Document.createElement(String tagName) doesn't accept
      ":", ":xxx" and "xxx:" as valid element names. It throws DOMException with INVALID_CHARACTER_ERR
      error code (See test.java below).
        
        The XML 1.0 specification defines the element name format (http://www.w3.org/TR/REC-xml#NT-Name):
        
                 Name ::= (Letter | '_' | ':') (NameChar)*
                 
        Hence ":", ":xxx" and "xxx:" names are valid.
        
        This bug appears in builds jaxp-1.1.1-b23-25_feb_2001, jaxp-1.1.1-b23-28_feb_200 and affects the
      test in TCK JAXP 1.1
        
             api/com/sun/xml/tests/dom/DocumentTest.html#createElement001
             api/org_w3c_dom/Document/CreateElementTests.html#createElementTest01
             
      ------------------------------------test.java-----------------------------
      import org.w3c.dom.Document;
      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.parsers.DocumentBuilder;

      public class test {
          
          public static void main(String argv[]) {
              String[] names = new String[] {":", ":xxx", "xxx:"};
              
              for (int i = 0; i < names.length; i++) {
                  try {
                      Document doc = DocumentBuilderFactory.newInstance()
                                               .newDocumentBuilder().newDocument();
                  
                      doc.createElement(names[i]);
                      System.out.println("name '" + names[i] + "' - OKEY");
                  } catch (Exception e) {
                      System.out.println("name '" + names[i] + "' - " + e);
                  }
              }
          }
      }
      ---------------------------------------------------------------------------
      ---------------------------------------------------------------------------
      % java -showversion -cp .:jaxp1.1.1/jaxp.jar:jaxp1.1.1/crimson.jar test
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, interpreted mode)

      name ':' - org.apache.crimson.tree.DomEx: INVALID_CHARACTER_ERR: An invalid character was
      specified, such as in a name.
      name ':xxx' - org.apache.crimson.tree.DomEx: INVALID_CHARACTER_ERR: An invalid character was
      specified, such as in a name.
      name 'xxx:' - org.apache.crimson.tree.DomEx: INVALID_CHARACTER_ERR: An invalid character was
      specified, such as in a name.
      ---------------------------------------------------------------------------
             
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            egoei Edwin Goei (Inactive)
            Reporter:
            evgsunw Evg Evg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: