如何以结构化方式返回Schematron验证结果 [英] How do I return Schematron validation results in a structured manner

查看:104
本文介绍了如何以结构化方式返回Schematron验证结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了几个Schematron断言,它们对我的XML实例都运行良好.但是,我想以这样一种方式来构造错误消息的输出,以便以后可以使用Java对它们进行后处理.

I have created several Schematron assertations and they are all running fine against my XML instances. However, I would like to structure the output of my error messages in such a way, that I later can post-process them, with e.g., Java.

我的断言错误消息的输出应该是

The output of my assertion error message should be

<error>
  <errorMessage>My error message</errorMessage>
  <violatingElement>The violating element</violatingElement>
</error>

但是,例如:

<pattern>
  <rule context="/p1:Document/p1:Delivery/p1:DeliveryDetails/p1:ShippingDate">
    <report test=".">
      <error>
       <errorMessage>My error message</errorMessage>
       <violatingElement>The violating element</violatingElement>
      </error>
    </report>
 </rule>
</pattern>

不起作用.以结构化(XML标准化)的方式返回Schematron结果的正确方法是什么?

does not work. What is the correct way of returning Schematron results in a structured (XML-ified) manner?

推荐答案

实际上,要以XML格式获取Schematron报告,应使用SVRL.您可以在此处了解更多信息: Schematron验证报告语言(SVRL)

Actually to get a Schematron report as XML you should use SVRL. You can learn more about it here: Schematron Validation Report Language (SVRL)

使用SVRL的最大优点是,您还可以获得有关在何处将断言/报告作为XPath触发的详细信息.

The big advantage of using SVRL is that you can also get detailed information about where the assertion/report was triggered as an XPath.

这篇关于如何以结构化方式返回Schematron验证结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆