【发布时间】:2018-10-10 17:12:34
【问题描述】:
我被要求研究在 MarkLogic 环境中使用 1.1 版 XML 模式将 Schematron 断言折叠到 XML 模式中。
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:assert test="..."/> 中的 <sch:name/> 或 <sch:value-of/> 标记之类的东西?
【问题讨论】:
-
MarkLogic 使用自己的引擎来验证 XML Schema 和 IIRC,它只支持 1.0 版,而不是 1.1 版。我不知道有任何特定于实现的扩展。
标签: marklogic saxon xerces schematron xsd-1.1