Skip to main content

jaxb validation against JAXB Java classes and not against xml schema

2 replies [Last post]
jduprez
Offline
Joined: 2009-05-04
Points: 0

Hello,

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?

http://forums.sun.com/thread.jspa?threadID=5379594
"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

http://forums.sun.com/thread.jspa?threadID=5384301
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.
peechramji
Offline
Joined: 2008-05-29
Points: 0

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

sarcasmmonster
Offline
Joined: 2009-08-06
Points: 0

This issue was filed a while back.

https://jaxb.dev.java.net/issues/show_bug.cgi?id=430

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.

https://jaxbvalidation.dev.java.net/