Reputation: 93
Does jackson have a validator for validating an xml against an xsd. I do not want to map the xml to a java class using jackson. If such kind of validation can be done using jackson, then how can I do it.
Upvotes: 2
Views: 6068
Reputation: 116620
No, Jackson can bind XML data to and from Java Objects, but it is not an XML tool.
You may be able to hook in XML Schema validator as part of processing, however: Woodstox (Stax parser) does support XML Schema validation. If so, you will need to construct XMLStreamReader
manually, make XmlMapper
use that -- it gets bit involved but is theoretically possible.
But instead of XML Schema, you might want to consider using Bean Validation (see f.ex. http://docs.oracle.com/javaee/6/tutorial/doc/gircz.html). Many frameworks support it, and it is more convenient and powerful for validating actual data, instead of underlying XML serialization.
Upvotes: 2