如何在MarkLogic中针对多个架构定义验证XML文件?

我正在MarkLogic数据库中工作,该数据库大约有130,000个XML文档。这些文档是使用MODS架构编写的,并在MODS扩展元素中使用了其他本地架构。我想要做的是针对官方的MODS 3.7 xsd和本地编写的schematron.sch文件验证这些文档。

如何针对mods-3.7.xsd和schematron.sch验证MODS命名空间中的所有元素?我们本地命名空间中的元素也需要根据schematron.sch进行验证。

我需要在MarkLogic中做什么以这种方式正确设置验证?

我尝试将mods-3.7.xsd和schematron.sch移到MarkLogic Sc​​hemas数据库中,然后将XML文档中的xsi:schemaLocation更新为 xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-7.xsd http://www.loc.gov/mods/v3 /Schemas/schematron.sch",然后使用xdmp:document-insert($new-uri,validate strict { $doc } )在MarkLogic查询控制台中测试验证。这只会返回错误: [1.0-ml] XDMP-VALIDATENODecl:(err:XQDY0084)validate strict {$ doc}-缺少元素声明:节点fn的期望声明:doc(“ / Apps / theocom-maggie /scripts/MODS-conversion/ia-to-mods.xsl")/mods:mods以非宽松模式使用模式“”

帮助!

rustybash 回答:如何在MarkLogic中针对多个架构定义验证XML文件?

请记住,schemaLocation中的模式uri是在Schemas数据库而不是在网络中解决的。

说实话,我认为在MarkLogic中最简单的方法是根本不使用xsi:schemaLocation属性,而是在xqy中显式导入架构(使用import schema语句),以确保找到它正确。

顺便说一下,约书亚对Schematron的看法是正确的。 validate语句不执行Schematron验证。但是,MarkLogic确实提供了schematron支持,您可以手动应用它:

https://docs.marklogic.com/schematron

该模式大致如下。首先,将schematron和架构上载到架构数据库中。然后,您需要使用类似以下的命令来编译schematron文件:

xquery version "1.0-ml";

import module namespace schematron = "http://marklogic.com/xdmp/schematron" 
      at "/MarkLogic/schematron/schematron.xqy";

schematron:put("/schematron.sch")

此后,您将使用导入架构并进行验证以进行架构和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,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!

本文链接:https://www.f2er.com/3150696.html

大家都在问