I have some annotated JAXB beans which I am using to unmarshal some XML.
I have several attributes annotated with @XMLAttribute with the type Boolean.
@XmlAttribute private Boolean someAttribute;
I would like to customise the umarshalling of all boolean attribute so that only exactly the values "true" or "false" are allowed (e.g. "FALse" and not "wibble" would cause the unmarshalling to fail).
I would prefer to avoid having to set an @XmlJavaTypeAdapter on every Boolean attribute if possible. Is there any way to configure how JAXB unmarshals Boolean properties?
You could create a Schema
expressing your constraints and attach this to the Unmarshaller
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With