eXist-db序列化是否为expand-xincludes = no忽略?

时间:2019-01-16 10:36:22

标签: xquery exist-db

在eXist-db 4.4(Xquery 3.1)中,我正在将许多XML文件压缩为目录中的.zip。压缩过程使用serialize()

XML文件具有一些较大的xincludesaccording to the documentation会在序列化过程中自动处理。我试图在代码的两个位置(prologue declaremap)“关闭” xinclude序列化,但是序列化器仍在输出所有xincludes:

declare option exist:serialize "expand-xincludes=no";
declare function zip:get-entries-for-zip() 
{
  (: get documents prefixed by 'MS609' :)
  let $pref := "MS609"

  (: get list of document names :)

  let $doclist := xmldb:get-child-resources($globalvar:URIdata)[starts-with(., $pref)]

  (: output serialized entries :)
  let $entries :=  
      for $n in $doclist
         return
            <entry name="{$n}" type='text' method='store'>
               {serialize(doc(concat($globalvar:URIdata, "/", $n)), map { "method": "xml", "expand-xincludes": "no"})}
            </entry>

   return $entries
};

可以在http://medieval-inquisition.huma-num.fr/downloads下的“ BM MS609 Edition(tei-xml)”描述下找到带有xincludes的XML数据。

非常感谢。

1 个答案:

答案 0 :(得分:1)

expand-xincludes serialization parameter特定于eXist,因此(或至少目前)不能使用fn:serialize()函数进行设置。而是使用util:serialize() function

util:serialize($document, "expand-xincludes=no")

或者,由于您最终对压缩集合的内容感兴趣,因此可以跳过显式的序列化步骤,在查询的序言中声明序列化选项(或使用util:declare-option()内联设置),然后简单地提供compression:zip() function到您要压缩的集合/文档的URI路径。例如:

xquery version "3.1";

declare option exist:serialize "expand-xincludes=no";

let $sources := "/db/apps/my-app/my-data" (: or a sequence of paths to individual docs:) ! xs:anyURI(.)
let $preserve-collection-structure := false()
let $zip := compression:zip($sources, $preserve-collection-structure), 
return
    xmldb:store("/db", "my-data.zip", $zip)

有关eXist中的序列化选项的更多信息,请参阅我先前对类似问题的答案:https://stackoverflow.com/a/49290616/659732