-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
5.0
-
sparc
-
generic
I am using Java 5 or Java 6.
The following test case fails 100%.
// Create an array of sources
final InputStream xsd = new FileInputStream("src/xml.xsd");
StreamSource[] sources = new StreamSource[1];
sources[0] = new StreamSource(xsd);
// Create the Schema Factory
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
[code]
// Create a schema
Schema schema1 = schemaFactory.newSchema(sources);
// Create a second schema, it will throw an Excepion
Schema schema2 = schemaFactory.newSchema(sources);
If you are creating a new array of sources before to create the second schema, it works fine. It seems that SchemaFactory.newSchema is making the passed sources as not "reusable"
I can't use new StreamSource(File) that is working. I need to work at the Stream level.
Thrown Exception :
Exception in thread "main" org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at [/code]com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2245)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchema(XSDHandler.java:1590)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:438)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:556)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:523)
at com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:206)
at javaapplication5.Main.main(Main.java:55)
The following test case fails 100%.
// Create an array of sources
final InputStream xsd = new FileInputStream("src/xml.xsd");
StreamSource[] sources = new StreamSource[1];
sources[0] = new StreamSource(xsd);
// Create the Schema Factory
final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
[code]
// Create a schema
Schema schema1 = schemaFactory.newSchema(sources);
// Create a second schema, it will throw an Excepion
Schema schema2 = schemaFactory.newSchema(sources);
If you are creating a new array of sources before to create the second schema, it works fine. It seems that SchemaFactory.newSchema is making the passed sources as not "reusable"
I can't use new StreamSource(File) that is working. I need to work at the Stream level.
Thrown Exception :
Exception in thread "main" org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'null', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at [/code]com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaError(XSDHandler.java:2245)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchema(XSDHandler.java:1590)
at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:438)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:556)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadGrammar(XMLSchemaLoader.java:523)
at com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaFactoryImpl.newSchema(SchemaFactoryImpl.java:206)
at javaapplication5.Main.main(Main.java:55)