문제

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?

도움이 되었습니까?

해결책

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).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top