Reputation: 308
I am using the JAXB
parser to convert XML
to a Java object. I have generated the JAXB
files from the XML
schema (XSD)
.
While passing the XML
String , I defined xsi:noNamespaceSchemaLocation='Typetest.xsd'
. So this will validate the XML
document against the XML
schema Typetest.xsd
.
But my question is that I never defined the path for the JAXB
parser to grab the schema file.
So how will JAXB
determine the path ?
<book xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="TypeTest.xsd">
</book>
Upvotes: 2
Views: 457
Reputation: 148977
To enable validation on the unmarshal
operation you must set an instance of Schema
on the Unmarshaller
.
Below is a link to an example on my blog:
Upvotes: 2