【发布时间】:2012-10-16 22:19:18
【问题描述】:
我正在针对多个 XSD 模式验证一个 xml 实例。如果验证失败,我想确定 xml 实例失败的架构。 SAXParseException 没有包含足够的信息来确定这一点。
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Source[] sources = getXsdSources();
Schema schema = factory.newSchema(sources);
Validator validator = schema.newValidator();
try {
validator.validate(input);
} catch (SAXParseException e) {
// Error handling.
}
【问题讨论】:
标签: java validation xsd