users@jaxb.java.net

Re: JAXB Validation project only for JAXB 1?

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Tue, 3 Aug 2010 09:07:49 +0200

Hi Glen,

> Hello, the JAXBValidation project (https://jaxbvalidation.dev.java.net/)
> looks pretty good, but I believe it's only for JAXB 1 and not JAXB2,
> correct?

It's my project and it's only for JAXB 1. The project was indeed very
good for JAXB 1, but it's not portable to JAXB 2.

> If it is also for JAXB2, would it be also useful in CXF's wsdl2java plugin
> (or Metro wsimport equivalent), or it really doesn't provide much more in
> terms of message/schema validation already offered by CXF
> (https://cwiki.apache.org/confluence/display/CXF20DOC/Annotations) and
> Metro's ( https://jax-ws.dev.java.net/guide/Schema_Validation.html) own
> tools?

JAXBValidation basically implemented schema-validation on object
level. That is, JAXB add-on analyzed the schema and generated
"validators" which could check JAXB object structures (not XML!). The
benefit is that you can report problems on object level (that is,
property "foo" in object "bar" is wrong).

Back then there were no bean validation API (JSR 303), so validators
were generated as Java classes. On JAXB 2 I would definitely go with
JSR 303 annotations. This also fits the JPA (Hyperjaxb3) way very
well.

Recently I did some experiments. I can imagine a JAXB 2 plugin which
analyzes the schema and generates JSR 303 annotations which describe
how the bean must be validated. In this case bean validator may report
XML Schema validation errors with locations in the object structure.

However the task is rather difficult.

Bye.
/lexi