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

TypeInfo.isDerivedFrom(...) throws UnsupportedOperationException

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Name: erR10175 Date: 12/10/2003


         
            If a TypeInfo instance refers to a simple type, the method TypeInfo.isDerivedFrom(...)
        throws UnsupportedOperationException. The documentation of the method does not declare
        that any exception is thrown in such a case.

        This bug affects new test in JCK 1.5 (not integrated yet)
           api/org_w3c/dom/TypeInfo/index.html#TypeInfo[IsDerivedFrom003]

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

        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 org.w3c.dom.Document;
        import org.w3c.dom.TypeInfo;
        import javax.xml.XMLConstants;
        import javax.xml.parsers.DocumentBuilderFactory;

        class test {
            static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
            static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource";

            public static void main(String[] args) throws Exception {

                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                dbf.setNamespaceAware(true);
                dbf.setValidating(true);
                dbf.setAttribute(SCHEMA_LANGUAGE, XMLConstants.W3C_XML_SCHEMA_NS_URI);
                dbf.setAttribute(SCHEMA_SOURCE, "test.xsd");

                Document document = dbf.newDocumentBuilder().parse("test.xml");

                TypeInfo type = document.getDocumentElement().getSchemaTypeInfo();

                if (type.isDerivedFrom("testNS", "Test", TypeInfo.DERIVATION_UNION)) {
                    System.out.println("isDerivedFrom returns true");
                } else {
                    System.out.println("OK");
                }
            }
        }
        ----------------------------------------------------

        ------------------------------------------- test.xsd
        <?xml version="1.0"?>
        <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                    xmlns:testNS="testNS"
                    targetNamespace="testNS" elementFormDefault="qualified">
            
            <xsd:element name="test5">
                <xsd:simpleType>
                    <xsd:restriction base="xsd:string"/>
                </xsd:simpleType>
            </xsd:element>

            <xsd:complexType name="Test">
                <xsd:sequence>
                    <xsd:element name="description" minOccurs="0"/>
                    <xsd:element name="code"/>
                </xsd:sequence>
            </xsd:complexType>

        </xsd:schema>
        ----------------------------------------------------

        ------------------------------------------- test.xml
        <?xml version='1.0'?>
        <test5 xmlns="testNS">the test</test5>
        ----------------------------------------------------

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

        Exception in thread "main" java.lang.UnsupportedOperationException
                at com.sun.org.apache.xerces.internal.impl.dv.xs.XSSimpleTypeDecl.isDerivedFrom(XSSimpleTypeDecl.java:2736)
                at test.main(test.java:22)
        ----------------------------------------------------

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

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: