我可以从验证器中获取例如节点结构或类似的东西吗?像监听器或处理程序之类的东西。例外是不够的。我必须选择发生错误的节点。这就是我到目前为止所构建的。
def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
def schema = factory.newSchema(new StreamSource(new FileReader("src/import.xsd")))
def validator = schema.newValidator()
try {
validator.validate(new StreamSource(new FileReader("src/import.xml")))
println "everything is fine"
} catch(SAXException e) {
println e
}
谢谢你。