|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
Does woodstox support substitutionGroup schema element?I'm using woodstox 4.0.5 to validate xml files against a W3C (.xsd) schema file. All is good until I use the "substitutionGroup" schema element.
XML Snippet: ... ... <xs:element name="name" type="xs:string"/> <xs:element name="navn" substitutionGroup="name"/> ... ... //my validate routine public void validate (String xmlInputFile, String xsdSchemaFile) { // First, let's parse schema object XMLValidationSchemaFactory sf = XMLValidationSchemaFactory .newInstance(XMLValidationSchema.SCHEMA_ID_W3C_SCHEMA); File schemaFile = new File(xsdSchemaFile); XMLValidationSchema validationSchema = null; try { validationSchema = sf.createSchema(schemaFile); } catch (XMLStreamException xe) { System.err.println("Failed to process the Schema file ('" + schemaFile + "'): " + xe); xe.printStackTrace(); System.exit(1); } // And then validate a document: File inputFile = new File(xmlInputFile); try { XMLInputFactory2 ifact = (XMLInputFactory2) XMLInputFactory .newInstance(); XMLStreamReader2 sr = ifact.createXMLStreamReader(inputFile); try { sr.validateAgainst(validationSchema); /* * Document validation is done as document is read through (ie. * it's fully streaming as well as parsing), so just need to * traverse the contents. */ while (sr.hasNext()) {... sr.next(); } } catch (XMLValidationException vex) { System.err.println("Document '" + inputFile + "' failed validation: " + vex); System.exit(1); } } catch (XMLStreamException xse) { System.err.println("Failed parse the input document ('" + inputFile + "'): " + xse); System.exit(1); } System.out.println("Document '" + inputFile + "' succesfully validated."); }//end validate() The exception thrown is: Exception in thread "main" java.lang.Error at com.sun.msv.grammar.xmlschema.ElementDeclExp.getTypeDefinition(ElementDeclExp.java:340) at com.sun.msv.reader.xmlschema.XMLSchemaReader.isSubstitutable(XMLSchemaReader.java:881) at com.sun.msv.reader.xmlschema.XMLSchemaReader.wrapUp(XMLSchemaReader.java:786) at com.sun.msv.reader.xmlschema.RootState.endSelf(RootState.java:28) at com.sun.msv.reader.SimpleState.endDocument(SimpleState.java:111) at org.xml.sax.helpers.XMLFilterImpl.endDocument(XMLFilterImpl.java:473) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocument(AbstractSAXParser.java:737) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:515) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) at com.sun.msv.reader.GrammarReader._parse(GrammarReader.java:456) at com.sun.msv.reader.GrammarReader.parse(GrammarReader.java:444) at com.sun.msv.reader.xmlschema.XMLSchemaReader.parse(XMLSchemaReader.java:83) at com.ctc.wstx.msv.W3CSchemaFactory.loadSchema(W3CSchemaFactory.java:69) at com.ctc.wstx.msv.BaseSchemaFactory.createSchema(BaseSchemaFactory.java:107) at com.ctc.wstx.msv.BaseSchemaFactory.createSchema(BaseSchemaFactory.java:117) at ValidationApp.validate(ValidationApp.java:29) at ValidationApp.main(ValidationApp.java:76) I've validated the file using other parsers so I know the xml is actually valid. Any ideas? --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |