Loading TOC...


   manifest as Array|Node,
   nodes as Array|Sequence
) as binary()


Create a zip file from a list of nodes.

manifest The zip manifest should have the native JavaScript form:
      "lastModified": "2015-04-02T09:50:38",
      "path": "archive/friends.jpg"
      "path": "archive/notes.txt"
Any property other than path and lastModified are ignored. If the lastModified property 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). The element form is accepted but deprecated.
nodes The nodes that you want to zip up. The nodes correspond to the objects in the manifest (named 'part' in the XQuery version), where the first node corresponds to the first part object specified, the second node to the second part object, and so on. Specifying a different number of part objects than nodes will result in an error.

Usage Notes

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

The 'part' objects 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.zipCreate will not compress the first part if it is named "mimetype".


var zip = xdmp.zipCreate(
                   "path": "/mydoc.xml"
                   "lastModified": "2014-10-02T09:50:00",
                   "path": "/mypicture.jpg"
                [cts.doc("/mydoc.xml"), cts.doc("/mypicture.jpg")]);
xdmp.save("/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 

var x = new NodeBuilder();
var mimedoc = x.startDocument().addText("application/epub+zip").endDocument().toNode();

var zip = xdmp.zipCreate(
xdmp.save("/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.