MarkLogic使用什么引擎来根据XML Schema 1.1版验证XML文档?

时间:2018-04-30 15:11:54

标签: marklogic saxon xerces schematron xsd-1.1

我被要求在MarkLogic环境中使用版本1.1 XML Schema来将Schematron断言折叠到XML Schema中。

XSD 1.1未指定的一件事是使用Schematron文件中的自定义错误消息。

我发现Saxonica和Xerces都有扩展来解决这个问题。

以下是Saxonica处理此问题的方式:

<xs:element name="date">
  <xs:simpleType>
     <xs:restriction base="xs:date" xmlns:saxon="http://saxon.sf.net/">
       <xs:assertion test=". lt current-date()"
                  saxon:message="The date must not be in the future"/>
       <xs:pattern value="[^Z:]*" 
                  saxon:message="The date must not have a timezone"/>
     </xs:restriction>   
  </xs:simpleType>
</xs:element>

以下是Xerces处理此问题的方式:

  <xs:simpleType name="myPrecisionDecimal">
    <xs:restriction base="xs:decimal" xmlns:xerces="http://xerces.apache.org">
       <xs:totalDigits value="6" />
       <xs:fractionDigits value="4" />
       <xs:assertion test="string-length(substring-after(string($value), '.')) ge 2" 
              xerces:message="minScale of this decimal number should be 2" />
    </xs:restriction>
  </xs:simpleType>

另外:这些扩展程序中的任何一个都可以处理Schematron assert代码<sch:name/>中的<sch:value-of/><sch:assert test="..."/>代码吗?

1 个答案:

答案 0 :(得分:0)

关于Saxon,没有办法对消息进行参数化。但是,您可以要求Saxon生成XML格式的报告,其中包含有关无效的所有信息以及有关它们出现位置的上下文信息,您可以对此报告运行转换以将信息组合成您喜欢的任何形式(例如,包括,一个交互式演绎,显示带有无效元素的源文档。)