如何限制特定命名空间文档在 marklogic 中加载?

问题描述 投票:0回答:1

我有大量的数据,因为我也有 .svg 文件格式,它有 xlink 命名空间,但很少有 svg 文档没有 xlink 命名空间,在加载到 MarkLogic 时必须跳过这些文档。

那么,在从文件系统读取数据时,我可以使用哪个函数来读取名称空间以进行过滤或限制。

我正在使用 xdmp:document-get("file path") 从文件系统读取文档。

带有 xlink NS 的示例 xml -

<Books xmlns="http:books.com" xmlns:xlink="http://www.w3.org/1999/xlink">
<book/>
</Books>

Sample xml without xlink NS -

<Books xmlns="http:books.com" >
<book/>
</Books>
xml xquery marklogic-10 xlink
1个回答
0
投票

要确定

SVG
文档是否包含
xlink
命名空间,使用
fn:namespace-uri-for-prefix
加载文档后使用
xdmp:document-get
函数。

举个例子:

let $doc := xdmp:document-get("file path")
let $xlink-uri := fn:namespace-uri-for-prefix("xlink", $doc)
return
  if ($xlink-uri eq "http://www.w3.org/1999/xlink") then
    (: Document has xlink namespace, continue processing :)
    xdmp:document-insert("/path/to/save/document.xml", $doc)
  else
    (: Document does not have xlink namespace, skip this document :)
    ()
© www.soinside.com 2019 - 2024. All rights reserved.