Validating XML with multiple XSDs in Java
- by Arian
Hello!
I want to parse an XML file with Java and validate it in the same step against an XSD schema. An XML file may contain content of several schemas, like this:
<outer xmlns="my.outer.namespace" xmlns:x="my.third.namespace">
<foo>hello</foo>
<inner xmlns="my.inner.namespace">
<bar x:id="bar">world</bar>
</inner>
</outer>
Given a namespace the corresponding xsd file can be provided, but the used namespaces are unknown before parsing. If a schema defines default values for attributes, I also want to know that somehow.
I was able to validate a file if the schemas are known, I was able to parse a file without validation and I implemented a LSResourceResolver. However, I can't get all of it working together. How do I have to set up my (SAX) parser?