Validating XML with multiple XSDs in Java
Posted
by Arian
on Stack Overflow
See other posts from Stack Overflow
or by Arian
Published on 2010-05-13T17:56:41Z
Indexed on
2010/05/13
21:04 UTC
Read the original article
Hit count: 250
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?
© Stack Overflow or respective owner