请记住,schemaLocation 中架构的 uri 是在 Schemas 数据库中解析的,而不是在网络上解析的。
说实话,我认为在 MarkLogic 中最简单的方法是根本不使用 xsi:schemaLocation 属性,而是在 xqy 中显式导入模式(使用 import schema 语句),以确保它正确找到它。
顺便说一句,约书亚对 Schematron 的看法是正确的。 validate 语句不执行 Schematron 验证。但是,MarkLogic 确实提供了 schematron 支持,您可以手动应用它:
https://docs.marklogic.com/schematron
模式大致如下。您首先将 schematron 和 schema 上传到您的 schemas 数据库中。然后,您需要使用以下内容编译您的 schematron 文件:
xquery version "1.0-ml";
import module namespace schematron = "http://marklogic.com/xdmp/schematron"
at "/MarkLogic/schematron/schematron.xqy";
schematron:put("/schematron.sch")
之后,您使用 import schema and validate 来执行 schema 和 schematron 验证。比如:
import schema namespace mods = "http://www.loc.gov/mods/v3" at "/mods-3-6.xsd";
import module namespace schematron = "http://marklogic.com/xdmp/schematron"
at "/MarkLogic/schematron/schematron.xqy";
let $xml := <mods version="3.3" xmlns="http://www.loc.gov/mods/v3">
<titleInfo>
<title>FranUlmer.com -- Home Page</title>
</titleInfo>
<titleInfo type="alternative">
<title>Fran Ulmer, Democratic candidate for Governor, Alaska, 2002</title>
</titleInfo>
<name type="personal">
<namePart>Ulmer, Fran</namePart>
</name>
<genre>Website</genre>
<originInfo>
<dateCaptured point="start" encoding="iso8601">20020702 </dateCaptured>
<dateCaptured point="end" encoding="iso8601"> 20021203</dateCaptured>
</originInfo>
<language>
<languageTerm authority="iso639-2b">eng</languageTerm>
</language>
<physicalDescription>
<internetMediaType>text/html</internetMediaType>
<internetMediaType>image/jpg</internetMediaType>
</physicalDescription>
<abstract>Website promoting the candidacy of Fran Ulmer, Democratic candidate for Governor, Alaska, 2002. Includes candidate biography, issue position statements, campaign contact information, privacy policy and campaign news press releases. Site features enable visitors to sign up for campaign email list, volunteer, make campaign contributions and follow links to other internet locations. </abstract>
<subject>
<topic>Elections</topic>
<geographic>Alaska</geographic>
</subject>
<subject>
<topic>Governors</topic>
<geographic>Alaska</geographic>
<topic>Election</topic>
</subject>
<subject>
<topic>Democratic Party (AK)</topic>
</subject>
<relatedItem type="host">
<titleInfo>
<title>Election 2002 Web Archive</title>
</titleInfo>
<location>
<url>http://www.loc.gov/minerva/collect/elec2002/</url>
</location>
</relatedItem>
<location>
<url displayLabel="Active site (if available)">http://www.franulmer.com/</url>
</location>
<location>
<url displayLabel="Archived site">http://wayback-cgi1.alexa.com/e2002/*/http://www.franulmer.com/</url>
</location>
</mods>
return
schematron:validate(
validate strict { $xml},
schematron:get("/schematron.sch")
)
HTH!