更新时间:2023-09-18 07:58:40
当您的 zip 绑定 compression:zip()
函数.我建议使用 fn:serialize()
函数显式设置序列化选项.以下示例代码展示了如何实现您所描述的结果:
xquery 版本3.1";let $node := <html><head/><body><div><h1>Hello World!</h1></div></body></html>让 $serialized := serialize($node, map { "method": "xml", "indent": true(),省略 xml 声明":true() })let $entries := <entry name="test.html" type="text" method="store">{$serialized}</entry>让 $filename := "test.zip"返回响应:流二进制(压缩:zip($entries, true()),'应用程序/zip',$文件名)
将此查询保存到数据库中的/db/apps/my-app/test.xq
位置,并通过将您的网络浏览器指向http://localhost:8080/exist/apps/my-app/test.xq 将导致您的浏览器下载 test.zip
.打开这个 zip 文件将显示一个没有 XML 声明的 test.html
文件:
<头/><身体><div><h1>你好世界!</h1>