【发布时间】:2018-08-27 13:11:07
【问题描述】:
我在 MarkLogic 中使用 schematron API 来验证 XML 文档。下面是sn-p的代码供参考。
xquery version "1.0-ml";
import module namespace sch = "http://marklogic.com/validate" at
"/MarkLogic/appservices/utils/validate.xqy";
import module namespace transform = "http://marklogic.com/transform" at "/MarkLogic/appservices/utils/transform.xqy";
declare namespace xsl = "http://www.w3.org/1999/XSL/not-Transform";
declare namespace iso = "http://purl.oclc.org/dsdl/schematron";
let $document :=
document{
<book xmlns="http://docbook.org/ns/docbook">
<title>Some Title</title>
<chapter>
<para>...</para>
</chapter>
</book>
}
let $schema :=
<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns:db="http://docbook.org/ns/docbook">
<s:ns prefix="db" uri="http://docbook.org/ns/docbook"/>
<s:pattern name="Glossary 'firstterm' type constraint">
<s:rule context="db:chapter">
<s:assert test="db:title">Chapter should contain title</s:assert>
</s:rule>
</s:pattern>
</s:schema>
return
sch:schematron($document, $schema)
谁能帮我获取上下文节点的 XPath 信息以及 schematron 错误消息输出。
【问题讨论】:
-
您可以尝试基于 XSLT 的 schematron 验证,而不是使用 ML schematron 验证 API,通过它您可以轻松获得 XPATH。看看 SVRL
标签: xquery xslt-2.0 marklogic schematron