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

Error while validating Schemas as Source[] (since 1.6)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 6
    • xml

      FULL PRODUCT VERSION :
      (do not work)
      java version "1.6.0"
      Java(TM) SE Runtime Environment (build 1.6.0-b105)
      Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode, sharing)

      (work)
      java version "1.5.0_09"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
      Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_09-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux cli004 2.6.11.4-21.12-default #1 Wed May 10 09:38:20 UTC 2006 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      With JDK 1.6, validating an XML File want work anymore like it in JDK 1.5 does.

      I think it seems to be a problem with creating a Schema like:
      javax.xml.validation.SchemaFactory.newSchema(Source[] schemas)
      After executing this, i got that error:
      s4s-elt-schema-ns: The namespace of element 'xs:schema' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.

      I found an similiar Problem in Forums:
      http://forum.java.sun.com/thread.jspa?threadID=5134606

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      For testing you need Shema-Files and an XML File. You can download my Sample-Files I used here:

      datei1
      datei2
      datei3
      datei4

      .. next see SourceCode


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
       org.xml.sax.SAXParseException: s4s-elt-schema-ns: The namespace of element 'xs:schema' must be from the schema namespace, 'http://www.w3.org/2001/XMLSchema'.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2529)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSAttributeChecker.reportSchemaError(XSAttributeChecker.java:1608)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSAttributeChecker.checkAttributes(XSAttributeChecker.java:1028)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSAttributeChecker.checkAttributes(XSAttributeChecker.java:996)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDocumentInfo.<init>(XSDocumentInfo.java:100)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.constructTrees(XSDHandler.java:728)
      at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:569)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:552)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:519)
      at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:485)
      at com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory.newSchema(XMLSchemaFactory.java:206)
      at constants.schema.JGAEB_Schema.validate(JGAEB_Schema.java:111)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public Source[] getSources() {
      // generating the Source Array
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder;
      DOMSource[] sources = new DOMSource[3];
      builder = factory.newDocumentBuilder();

      factory.setValidating(false);
      factory.setNamespaceAware(true);

      Node docRoot1 = builder.parse(new File("/path/to/xml.xsd"));
      Node docRoot2 = builder.parse(new File("/path/to/xmldsig-core-schema.xsd"));
      Node docRoot3 = builder.parse(new File("/path/to/GAEB_DA_XML.xsd"));

      sources[0] = new DOMSource(docRoot1);
      sources[1] = new DOMSource(docRoot2);
      sources[2] = new DOMSource(docRoot3);

      return sources;
      }


      // Validating the XML-File
      public void validate() {
      DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
      Document xmldoc = docBuilder.parse(new File("/path/to/2004-003.X86"));

      SchemaFactory schema_factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

      Schema schema = schema_factory.newSchema(getSources()); // HERE ERROR (JGAEB_Schema.java:111)

      Validator validator = schema.newValidator();
      validator.validate(new DOMSource(xmldoc));
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      work with JRE 1.5

      Release Regression From : 5.0u9
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

      Release Regression From : 5.0u9
      The above release value was the last known release where this
      bug was not reproducible. Since then there has been a regression.

            spericas Santiago Pericasgeertsen
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: