0

Validate XML against an XSD that imports other XSDs

This post demonstrates how to validate XML against XSD that imports other XSDs. This is different from validating against multiple independent XSDs.

Sample XSD Files

For our purpose, we have 4 XSD files.

Java codes

As usual we need a Schema object to validate an XML file. The following codes creates that object from using the main XSD file – Main.xsd. Given how our XSDs are authored, there is no need to specify the other XSD files in the codes.

The following set of codes use the Schema object to validate against an XML file.

Sample output:

Download the codes

https://github.com/Turreta/Validate-XML-against-an-XSD-that-imports-other-XSDs