Skip to main content

jaxb validation against JAXB Java classes and not against xml schema

2 replies [Last post]
Joined: 2009-05-04


a couple of questions (one from myself) were asked on the JDC forum "Java Technology and XML", with no answer. I hope to have more info here:

Why does JAXB need the schema source at runtime to perform validation?
"JAXB method Unmarshaller.setValidating(boolean) has been deprecated in favor of Unmarshaller.setSchema(Schema) (...)
The drawback of this approach is that you have to supply a Schema instance [passing null disables validation]
But when the binding classes have been generated from the schema source, I would think they contain all the information needed to validate XMl files against the schema. Is that the case? And if so, why is the schema source needed at runtime? If not, is it a design choice that the XJC compilation ommits the missing information?"

jaxb validation against JAXB Java classes and not against xml schema
I would like to know if it is possible to validate a xml document against JAXB Java classes and not against xml schema. Let's assume for some reason I don't
have access to xml schema. I searched on Internet by simple examples
in tutorials show only validation against schema file.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-05-29

Were you able to find the solution to this problem. I am looking for answers to the same.

Joined: 2009-08-06

This issue was filed a while back.

It seems like a logical feature for the library to handle. After all, most of us do compile through a schema to begin with. Intuitively, JAXB would adhere to it. Unfortunately, the dev's are showing no interest in the bug report. Vote for it I suppose. I too would like to see this resolved.

This looks like a promising project in the future. Haven't tried it though. It's rather obscure project so I wouldn't rely on it.