Changes

Jump to navigation Jump to search
2,222 bytes added ,  20:41, 28 May 2012
Created page with "This XQuery Module contains functions to handle ZIP archives. New ZIP archives can be created, existing archives can be updated, and the archive entries can be..."
This [[Module Library|XQuery Module]] contains functions to handle ZIP archives. New ZIP archives can be created, existing archives can be updated, and the archive entries can be listed and extracted. This module may eventually replace the existing [[ZIP Module]] as soon as it is finalized and adopted by other XQuery implementations.

=Conventions=

All functions in this module are assigned to the {{Code|http://basex.org/modules/zip2}} namespace, which is statically bound to the {{Code|zip2}} prefix.<br/>
All errors are assigned to the {{Code|http://basex.org/errors}} namespace, which is statically bound to the {{Code|bxerr}} prefix.

=Functions=

==zip:create==
{|
|-
| width='90' | '''Signatures'''
|{{Func|zip:create|$entries as element(entry)*, $contents as item()*|xs:base64Binary}}<br />
|-
| '''Summary'''
|Creates a new ZIP archive from the specified entries and contents.
The {{Mono|$entries}} elements 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.
The actual {{Mono|$contents}} must be {{Mono|xs:string}} or {{Mono|xs:base64Binary}} items.
|-
| '''Errors'''
|{{Error|FOZ20001|#Errors}} the number of entries and contents differs.<br />{{Error|FOZ20002|#Errors}} (some of) the contents are not strings or binaries.<br />{{Error|FOZ20003|#Errors}} (some of) the entries elements contain invalid data.{{Error|FOZ20004|#Errors}} the specified encoding is invalid or not supported.<br/>{{Error|FOZ2999|#Errors}} archive processing failed for some other reason.
|-
| '''Examples'''
|The following function creates a file {{Code|archive.zip}} with the file {{Code|file.txt}} inside:
<pre class="brush:xquery">
zip:create(
<file xmlns="http://expath.org/ns/zip" href="archive.zip">
<entry src="file.txt"/>
</file>)
</pre>
The following function creates a file {{Code|archive.zip}}. It contains one file {{Code|readme}} with the content "{{Code|thanks}}":
<pre class="brush:xquery">
zip:zip-file(
<file xmlns="http://expath.org/ns/zip" href="archive.zip">
<entry name="readme">thanks</entry>
</file>)
</pre>
|}

[[Category:XQuery]]
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu