views:

89

answers:

1

Hello All,
JAXB Generated classes only capture the structural information from the XML schema that is used to generate the classes, but they ignore any additional constraints on the data e.g allowed set of values(enumerations), max value allowed etc. Does it mean that if i do not have a schema i can only validate structural information and not the constraints on the data? If so why was this not allowed with JAXB, annotations could have very well also caputred the constraints?


Best Regards,
Keshav

+2  A: 

This is not part of the JAXB 2 specification. If you have an XML schema you can set it on the Unmarshaller to enable validation. You can add bean validation JSR 303 annotations to your model.

Blaise Doughan