|-
| '''Summary'''
|Creates a new ZIP archive from the specified entries and contents.<br/>The {{Code|$entries}} elements descriptors contain meta information required to create new ZIP entries. Beside the mandatory entry name, optional attributes can be specified, which contain the timestamp, compression level and encoding of textual entries. An Example:
<pre class="brush:xml">
<entry last-modified='2011-11-11T11:11:11'
|-
| '''Errors'''
|{{Error|FOZ20001|#Errors}} the number of entries and contents differs.<br />{{Error|FOZ20002|#Errors}} (some of) the contents are not of type {{Code|xs:string}} or {{Code|xs:base64Binary}}.<br />{{Error|FOZ20003|#Errors}} entries elements entry descriptors contain invalid data.<br/>{{Error|FOZ20004|#Errors}} the specified encoding is invalid or not supported.<br/>{{Error|FOZ29999|#Errors}} archive processing creation failed for some other reason.
|-
| '''Examples'''
|The following function one-liner creates an archive {{Code|archive.zip}} with one file {{Code|file.txt}}:
<pre class="brush:xquery">
zip2:create(<entry>file.txt</entry>, 'Hello World')
</pre>
|The following function create a {{Code|mp3.zip}} archive containing all mp3 files of a directory:
<pre class="brush:xquery">
let $path := 'audio/'
let $entries := file:list($path, true(), '*.mp3')
let $zip := zip2:create(
for $e in $entries
return element entry { $e },
for $e in $entries
return file:read-binary($path || $e)
)
return file:write-binary('mp3.zip', $zip)</pre>
|}
[[Category:XQuery]]