开发者

JAXB 2.0 Validation Question

While working with JAXB 2.0 i came across a query which i am unable to solve so far,while doing the validation i have 2 options

1) Either as soon as i found the error throw the exception as i am done. 2) Move ahead if there is any error or validation and i assume this is the best way since it will help one to show all errors or warings with respect to the whole XML. but s开发者_如何学Goince this process also invlolves unmarshalling means it will unmarshall my provided XML is to respected Object even if there is any Error or warning.so all means extra work..

My question is is these a way so that i can do whole validation and if it is successfull only than should the corresponding XML be bind to respected POJO classes

thanks in advance


You can use the javax.xml.validation APIs to validate an XML document against an XML schema. The you can choose to unmarshal this object again using JAXB.

Below is an example of using these APIs. In this example the input is actually an object model, but you can adapt it to work with any XML input.

  • http://bdoughan.blogspot.com/2010/11/validate-jaxb-object-model-with-xml.html
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜