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

TypeInfo.getTypeNamespace() returns null for an attribute declared in DTD

    XMLWordPrintable

Details

    • b44
    • generic
    • generic
    • Verified

    Description

      Name: erR10175 Date: 03/11/2004



           If an attribute is declared in DTD, TypeInfo.getTypeNamespace()
      returns null instead of "http://www.w3.org/TR/REC-xml".

      The documentation of the interface org.w3c.dom.TypeInfo reads:

      "
      If the document's schema is an XML DTD [XML 1.0], the values are computed
      as follows:
      - If this type is referenced from an Attr node, typeNamespace is
         "http://www.w3.org/TR/REC-xml" and typeName represents the [attribute type]
          property in the [XML Information Set] . If there is no declaration for
          the attribute, typeNamespace and typeName are null.
      - ...
      "

      In the test (see below) there is an attribute declaration, so what expected is
      "http://www.w3.org/TR/REC-xml".

      This bug affects new test in JCK 1.5
          api/org_w3c/dom/TypeInfo/index.html#TypeInfo[GetTypeNamespace001]

      The bug is found in jdk1.5.0/beta/b41.

      To reproduce the bug place test.java, test.xsd and test.xml to your current
      directory, then compile and run test.java as shown in the log below:
      ------------------------------------------ test.java
      import javax.xml.parsers.DocumentBuilderFactory;
      import org.w3c.dom.Document;
      import org.w3c.dom.Attr;

      class test {
           public static void main(String[] args) throws Exception {
               Document document = DocumentBuilderFactory
                   .newInstance().newDocumentBuilder().parse("test.xml");
               Attr attr = document.getDocumentElement().getAttributeNode("attr");

               String typeNamespace = attr.getSchemaTypeInfo().getTypeNamespace();
               String expected = "http://www.w3.org/TR/REC-xml";
               if (!expected.equals(typeNamespace)) {
                   System.out.println("Failed: getTypeNamespace returns: "
                                    + typeNamespace + ", expected: " + expected);
               } else {
                   System.out.println("Passed");
               }
           }
      }
      ----------------------------------------------------

      ------------------------------------------- test.xml
      <?xml version='1.0'?>
      <!DOCTYPE root [
           ELEMENT root ANY
           ATTLIST root attr NMTOKEN #IMPLIED
      ]>
      <root attr="test"/>
      ----------------------------------------------------

      ------------------------------------------------ log
      $javac test.java && java -cp . -showversion test
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b41)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b41, mixed mode)

      Failed: getTypeNamespace returns: null, expected: http://www.w3.org/TR/REC-xml
      ----------------------------------------------------

      ======================================================================
      ###@###.### 2004-03-11

      Attachments

        Activity

          People

            vkorcl Venugopal K (Inactive)
            reysunw Rey Rey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: