eXist-db 序列化是否被 expand-xincludes=no 忽略? [英] eXist-db serialize is expand-xincludes=no ignored?

查看:23
本文介绍了eXist-db 序列化是否被 expand-xincludes=no 忽略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In eXist-db 4.4, Xquery 3.1, I am compressing a number of XML files to a .zip in a directory. The compression process uses serialize().

XML 文件有一些很大的 xincludes,其中 根据文档在序列化时自动处理.我试图在代码中的两个地方(prologue declaremap)关闭"xinclude 序列化,但序列化器仍在输出所有 xinclude:

The XML files have some large xincludes which according to the documentation are automatically processed in serializing. I have attempted to 'turn off' the xinclude serialization in two places in the code (prologue declare and map), but the serializer is still outputting all 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
};

可以在此处找到带有 xincludes 以重现此问题的 XML 数据 http://medieval-inquisition.huma-num.fr/downloads 在BM MS609 Edition (tei-xml)"描述下.

The XML data with xincludes to reproduce this problem can be found here http://medieval-inquisition.huma-num.fr/downloads under the description "BM MS609 Edition (tei-xml)".

非常感谢.

推荐答案

expand-xincludes 序列化参数 特定于 eXist,因此(或至少目前)无法使用 fn:serialize()<设置/代码> 功能.相反,使用 util:serialize() 函数:

The 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:声明选项()),并简单地提供 compression:zip() 函数 URI 路径到您的集合/文档想要拉链.例如:

Alternatively, since you're ultimately interested in zipping the contents of a collection, you can skip the explicit serialization step, declare your serialization options in the query's prolog (or set it inline using util:declare-option()), and simply provide the compression:zip() function the URI path(s) to the collections/documents you want to zip. For example:

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.

For more on serialization options in eXist, see my earlier answer to a similar question: https://stackoverflow.com/a/49290616/659732.

这篇关于eXist-db 序列化是否被 expand-xincludes=no 忽略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆