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

SchemaFactory.newSchema throws InternalError in case of DOMSource

    Details

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

      Description

      Name: eaR10174 Date: 12/22/2003


      The method

           javax.xml.validation.SchemaFactory.newSchema(Source[] schemas)

      throws InternalError in case when a Schema object is created from DOMSource.
      The method should support DOMSource inputs according to the javadoc.

      The bug affects new JCK1.5 tests (not integrated yet):

         api/javax_xml/validation/SchemaFactory/index.html#NewSchema[NewSchema005]
         api/javax_xml/validation/SchemaFactory/index.html#NewSchema[NewSchema006]

      The following test fails running on JDK 1.5.0-beta-b32.
      See below the test source and the execution log:
      ------------------------------------test.java-----------------------------
      import java.io.StringReader;
      import javax.xml.parsers.DocumentBuilder;
      import javax.xml.parsers.DocumentBuilderFactory;
      import javax.xml.transform.Source;
      import javax.xml.transform.dom.DOMSource;
      import javax.xml.validation.Schema;
      import javax.xml.validation.SchemaFactory;
      import org.w3c.dom.Node;
      import org.xml.sax.InputSource;

      public class test {

           public static void main(String argv[]) {
               try {
                   new test().run();
               } catch (Exception e) {
                   e.printStackTrace();
                   System.exit(1);
               }
           }

           public void run() throws Exception {
               String xsd = "<?xml version='1.0'?>\n"
                          + "<schema xmlns='http://www.w3.org/2001/XMLSchema&#39;\n"
                          + " xmlns:test='jaxp13_test1'\n"
                          + " targetNamespace='jaxp13_test1'\n"
                          + " elementFormDefault='qualified'>\n"
                          + " <element name='test'/>\n"
                          + "</schema>\n";

               SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
               DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
               if (!docBuilderFactory.isNamespaceAware()) {
                   docBuilderFactory.setNamespaceAware(true);
               }
               DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
               StringReader reader = new StringReader(xsd);
               InputSource inSource = new InputSource(reader);
               Node document = docBuilder.parse(inSource);
               DOMSource source = new DOMSource(document);

               Schema schema = schemaFactory.newSchema(new Source[] {source});
               if (schema == null) {
                   System.out.println("Failed: newSchema returned null.");
               } else {
                   System.out.println("OK");
               }
           }
      }
      --------------------------------------------------------------------------
      % java -showversion test
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)

      ERROR: ''
      javax.xml.transform.TransformerException: java.lang.NullPointerException
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:317)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchema(XSDHandler.java:1467)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:385)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:560)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:544)
      at
      com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:105)
      at test.run(test.java:42)
      at test.main(test.java:15)
      Caused by: java.lang.NullPointerException
      at
      com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.startElement(SchemaDOMParser.java:262)
      at com.sun.org.apache.xerces.internal.util.SAX2XNI.startElement(SAX2XNI.java:82)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(ToXMLSAXHandler.java:245)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.characters(ToXMLSAXHandler.java:564)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.characters(ToXMLSAXHandler.java:507)
      at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:236)
      at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:222)
      at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:161)
      at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:125)
      at
      com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:589)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:635)
      ... 8 more
      ---------
      java.lang.NullPointerException
      at
      com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.startElement(SchemaDOMParser.java:262)
      at com.sun.org.apache.xerces.internal.util.SAX2XNI.startElement(SAX2XNI.java:82)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.closeStartTag(ToXMLSAXHandler.java:245)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.characters(ToXMLSAXHandler.java:564)
      at com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.characters(ToXMLSAXHandler.java:507)
      at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:236)
      at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:222)
      at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:161)
      at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:125)
      at
      com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:589)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:635)
      at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:317)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchema(XSDHandler.java:1467)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:385)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:560)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:544)
      at
      com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:105)
      at test.run(test.java:42)
      at test.main(test.java:15)
      Exception in thread "main" java.lang.InternalError
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchema(XSDHandler.java:1472)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:385)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:560)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:544)
      at
      com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:105)
      at test.run(test.java:42)
      at test.main(test.java:15)
      --------------------------------------------------------------------------

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

        Attachments

          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: