Loading TOC...


   $manifest as node(),
   $nodes as node()+
) as binary()


Create a zip file from a list of nodes.

$manifest The zip manifest, which must be in the xdmp:zip namespace and conform to the zip.xsd schema, located in the marklogic-dir/Schemas directory. The manifest has the following basic form:
    <parts xmlns="xdmp:zip">
      <part last-modified="2009-03-23T19:30:32">path1</part>
      ...more parts
Any of the size or encrypted attributes in the manifest are ignored for xdmp:zip-create. Attributes other than uncompressed-size, compressed-size, encrypted, and last-modified will throw an error. If the last-modified attribute is specified, that date and time will be set for the part. Otherwise, if the node for the part comes from a database that tracks the last modified time of a document, that date and time will be used. The current date and time will be used if no other value is available. Due to a limitation in the zip file format, the time has a granularity of two seconds (e.g. 10:22:33 becomes 10:22:32).
$nodes The nodes that you want to zip up. The nodes correspond to part elements in the manifest, where the first node corresponds to the first part element specified, the second node to the second part element, and so on. Specifying a different number of <part> elements than nodes will result in an error.

Usage Notes

While you can create a zip file of encrypted content, xdmp:zip-create does not have the capability to encrypt the content to be zipped.

The <part> elements in the manifest should contain relative paths so the zip file can be unpacked into its own directory; do not start the path with a forward slash or a backslash.

To support creating Open Container Format archives for the EPUB format, xdmp:zip-create will not compress the first part if it is named "mimetype".


let $zip := xdmp:zip-create(
               <parts xmlns="xdmp:zip">
                (doc("/mydoc.xml"), doc("/mypicture.jpg")))
xdmp:save("c:/tmp/myzip.zip", $zip)

(: Creates a zip archive that includes the documents "/mydoc.xml"
 : and "/mypicture.jpg", then saves that to the filesystem. :)


(: the "mimetype" file will not be compressed, so as to support
   the EPUB format :)
let $zip := xdmp:zip-create(
               <parts xmlns="xdmp:zip">
                (document { "application/epub+zip" },
xdmp:save("c:/tmp/mydoc.epub", $zip)

(: Creates a zip archive that meets the OCF specification,
 : then saves that to the filesystem. :)

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.