What's the best way to validate an XML file against an XSD file?

前端 未结 13 1299
滥情空心
滥情空心 2020-11-22 07:37

I\'m generating some xml files that needs to conform to an xsd file that was given to me. What\'s the best way to verify they conform?

13条回答
  •  感情败类
    2020-11-22 08:27

    If you are generating XML files programatically, you may want to look at the XMLBeans library. Using a command line tool, XMLBeans will automatically generate and package up a set of Java objects based on an XSD. You can then use these objects to build an XML document based on this schema.

    It has built-in support for schema validation, and can convert Java objects to an XML document and vice-versa.

    Castor and JAXB are other Java libraries that serve a similar purpose to XMLBeans.

提交回复
热议问题