I wish to create a grammar able to validate both a full XML document and a fragment of it.
I have a set of documents aggregate in a “batch”. Each document has a set of meta-data:
<batch>
<document>
<metadata1 />
<metadata2 />
<metadata3 />
</document>
<document>
<metadata1 />
<metadata2 />
<metadata3 />
</document>
</batch>
My SpringBatch process splits the batch in documents (with StaxEventItemReader) I wish to validate a sub XML representing a single document:
<document>
<metadata1 />
<metadata2 />
<metadata3 />
</document>
I read here that I can’t use partial XSD to validate XML.
However, is there is a way, while avoiding duplication, to validate with two XSDs, where one would validate the fragment, and the other would validate the batch?