Note that there are some explanatory texts on larger screens.

plurals
  1. POIn Java: validate XML against multiple schema's, located @ difference server locations
    primarykey
    data
    text
    <p>In my program, I am generating a XML file, and need to validate that XML file against multiple schemas which are located on different URLs. Its required to validate that XML file against all schema in onetime only.</p> <p><strong>Source fragment:</strong></p> <pre><code>// here source array contain the locations of schemas, located at diff servers. Source[] source = { new StreamSource( new URL("http://localhost:8081/test1/testSchema1.xsd") .openStream()), new StreamSource( new URL( "http://ccr.internal.ericsson.com/test2/testSchema2.xsd") .openStream()) }; try { // Compile the schema, which loaded from schemaFileLocation. Schema schemaGrammar = schemaFactory.newSchema(source); // Create a validator for schema. Validator configValidator = schemaGrammar.newValidator(); // set error handler with validator. SchemaValidator schemaValidator = new SchemaValidator(); configValidator .setErrorHandler(schemaValidator.new MessageHandler()); // validate xml instance against the grammar. configValidator.validate(new StreamSource(new File("xmlFile.xml"))); System.out.println("\n"); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } </code></pre> <p><strong>When I run the above code fragment, I am get this error:</strong></p> <blockquote> <p>org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'xn:SubNetwork' to a(n) 'element declaration' component. at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaError(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.getGlobalDecl(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseLocal(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseLocal(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDAbstractParticleTraverser.traverseSeqChoice(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDAbstractParticleTraverser.traverseChoice(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.processComplexContent(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.traverseComplexTypeDecl(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDComplexTypeTraverser.traverseLocal(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseNamedElement(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDElementTraverser.traverseLocal(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.traverseLocalElements(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source) at org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source) at com.work.test.generateErrorLog(SchemaValidator.java:197)</p> </blockquote> <p>What is the problem in code? Is their is any other way to validate against multiple schema?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload