Question

If XML is generated by JAXB classes(not by XSD), I don't have an XSD to validate. How do I validate the XML? Does the JAXB does validation of XML automatically before it starts unmarshalling?

Était-ce utile?

La solution

If you don't have XSD, JAXB will still perform "structual" validation. For example if you have annotated JAXB class property with "required" or specified specific "accessorder" and the input XML doesn't confirm to the annotation's values you will get exception. However you won't be able to perform "data" validation like specific XML element is restricted to have "8" character length (I believe JEE7 will integrate BeanValidation and wish JAXB leverages this spec).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top