Can one validate marshalled XML with JAXB 2.0?

后端 未结 2 973
隐瞒了意图╮
隐瞒了意图╮ 2020-12-28 08:19

Apparently in version 2 of JAXB - the validator class has been deprecated - does this mean the marshaller is automatically validating your XML? If so it doesn\'t seem to be

2条回答
  •  情歌与酒
    2020-12-28 08:37

    If you are looking to verify the Java objects generate valid XML according to a schema, look at the JAXB-Verification project:

    https://jaxb-verification.dev.java.net/

    It is a JAXB RI plugin to xjc that will generate an ObjectVerifier implementation for the XML schema. This avoids having to marshal the Java objects in order to validate the XML.

提交回复
热议问题