<?xml version="1.0" encoding="UTF-8"?><api:function-page xml:base="/apidoc/8.0/xdmp.zipCreate.xml" generated="2015-10-07T16:36:00.016766-07:00" mode="javascript" xmlns:api="http://marklogic.com/rundmc/api"><api:function-name>xdmp.zipCreate</api:function-name><api:suggest>xdmp.zipcreate</api:suggest><api:suggest>xdmp</api:suggest><api:suggest>zipcreate</api:suggest><api:function-link mode="xquery" fullname="xdmp:zip-create">/apidoc/8.0/xdmp:zip-create.xml</api:function-link><api:function mode="javascript" name="zipCreate" type="builtin" lib="xdmp" category="Document Conversion" hidden="false" bucket="MarkLogic Built-In Functions" prefix="xdmp" namespace="http://marklogic.com/xdmp" fullname="xdmp.zipCreate"><api:summary>
  Create a zip file from a list of nodes.
</api:summary><api:params><api:param class="javascript" name="manifest" type="Array|Node" optional="false"><api:param-description>
  The zip manifest should have the native JavaScript form:

  <blockquote xmlns="http://www.w3.org/1999/xhtml"><pre xml:space="preserve">
  [
    {
      "lastModified": "2015-04-02T09:50:38",
      "path": "archive/friends.jpg"
    },
    {
      "path": "archive/notes.txt"
    }
  ]    </pre></blockquote>

    Any property other than <code xmlns="http://www.w3.org/1999/xhtml">path</code> and <code xmlns="http://www.w3.org/1999/xhtml">lastModified</code>
    are ignored. If the <code xmlns="http://www.w3.org/1999/xhtml">lastModified</code> 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.
  </api:param-description><api:param-name>manifest</api:param-name><api:param-type>Array|Node</api:param-type></api:param><api:param class="javascript" name="nodes" type="Array|ValueIterator" optional="false"><api:param-description>
    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.
  </api:param-description><api:param-name>nodes</api:param-name><api:param-type>Array|ValueIterator</api:param-type></api:param></api:params><api:return>binary()</api:return><api:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">While you can create a zip file of encrypted content,
  <code> <span class="javascript">xdmp.zipCreate</span></code> does not have the
  capability to encrypt the content to be zipped.</p> <p xmlns="http://www.w3.org/1999/xhtml">The 
  
  <span class="javascript"><code>'part'</code> objects</span> 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.</p> <p xmlns="http://www.w3.org/1999/xhtml">To support creating Open
  Container Format archives for the EPUB format, 
   
  <span class="javascript"><code>xdmp.zipCreate</code></span> will not
  compress the first part if it is named "mimetype".</p>
</api:usage><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
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,
		{outputEncoding:"utf8"});

=&gt; Creates a zip archive that includes the documents "/mydoc.xml"
   and "/mypicture.jpg", then saves that to the filesystem.

</pre></api:example><api:example class="javascript"><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
//  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(
            [{path:"mimetype"},
             {path:"META-INF/container.xml"},
             {path:"OEBPS/content.opf"},
             {path:"OEBPS/content.pdf"}
            ],
            [mimedoc,
             cts.doc("/my-doc/container.xml"),
             cts.doc("/my-doc/content.opf"),
             cts.doc("/my-doc/content.pdf")
             ]);
xdmp.save("/tmp/mydoc.epub", zip, {outputEncoding:"utf8"});

=&gt; Creates a zip archive that meets the OCF specification,
   then saves that to the filesystem.

</pre></api:example></api:function></api:function-page>