Created
November 5, 2012 11:11
-
-
Save simonharrer/4016692 to your computer and use it in GitHub Desktop.
Validating against multiple XSD files using the classpath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String path = "my/test/path/to/file.xml"; | |
SchemaFactory sFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); | |
Schema schema = sFactory.newSchema(new Source[]{ | |
new StreamSource(getClass().getResourceAsStream("/path/to/schema1.xsd")), | |
new StreamSource(getClass().getResourceAsStream("/path/to/schema2.xsd")) | |
}); | |
Validator validator = schema.newValidator(); | |
validator.validate(new StreamSource(new File(path))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment