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

eXist-db serialize is expand-xincludes=no ignored?

在 eXist-db 4.4、Xquery 3.1 中,我将一些 XML 文件压缩到目录中的 .zip。压缩过程使用serialize()

XML 文件有一些大的 xincludesaccording to the documentation 在序列化时自动处理。我试图在代码中的两个地方 'turn off' xinclude 序列化(prologue declaremap),但序列化程序仍在输出所有 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)".

下找到使用 xinclude 重现此问题的 XML 数据

非常感谢。

expand-xincludes serialization parameter is specific to eXist and, as such (or at least at present), cannot be set using the fn:serialize() function. Instead, use the util:serialize() function:

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

或者,由于您最终对压缩集合的内容感兴趣,您可以跳过显式序列化步骤,在查询的序言中声明序列化选项(或使用 util:declare-option()), and simply provide the compression:zip() function URI 内联设置您要压缩的 collections/documents 的路径。例如:

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 中序列化选项的更多信息,请参阅我之前对类似问题的回答: