Changes

Jump to navigation Jump to search
611 bytes added ,  14:15, 20 July 2022
no edit summary
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:entries|$archive as xs:base64Binary|element(archive:entry)*}}<br />
|-valign="top"
| '''Summary'''
|Returns the entry descriptors of the specified {{Code|$archive}}. A descriptor contains the following attributes, provided that they are available in the archive format:
</archive:entry>
</syntaxhighlight>
|-valign="top"
| '''Errors'''
|{{Error|error|#Errors}} archive creation failed.
|-valign="top"
|'''Examples'''
|Sums up the file sizes of all entries of a JAR file:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:options|$archive as xs:base64Binary|map(*)}}<br />
|-valign="top"
| '''Summary'''
|Returns the options of the specified {{Code|$archive}} in the format specified by {{Function||archive:create}}.
|-valign="top"
| '''Errors'''
|{{Error|format|#Errors}} The archive format is not supported.<br/>{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|A standard ZIP archive will return the following options:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:extract-text|$archive as xs:base64Binary|xs:string*}}<br/>{{Func|archive:extract-text|$archive as xs:base64Binary, $entries as item()*|xs:string*}}<br/>{{Func|archive:extract-text|$archive as xs:base64Binary, $entries as item()*, $encoding as xs:string|xs:string*}}<br/>
|-valign="top"
| '''Summary'''
|Extracts entries of the specified {{Code|$archive}} and returns them as texts.<br/>The returned entries can be limited via {{Code|$entries}}. The format of the argument is the same as for {{Function||archive:create}} (attributes will be ignored).<br/>The encoding of the input files can be specified via {{Code|$encoding}}.
|-valign="top"
| '''Errors'''
|{{Error|encode|#Errors}} the specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if {{Option|CHECKSTRINGS}} is turned off.<br />{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|The following expression extracts all {{Code|.txt}} files from an archive:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:extract-binary|$archive as xs:base64Binary|xs:base64Binary*}}<br/>{{Func|archive:extract-binary|$archive as xs:base64Binary, $entries as item()*|xs:base64Binary*}}
|-valign="top"
| '''Summary'''
|Extracts entries of the specified {{Code|$archive}} and returns them as binaries.<br/>The returned entries can be limited via {{Code|$entries}}. The format of the argument is the same as for {{Function||archive:create}} (attributes will be ignored).
|-valign="top"
| '''Errors'''
|{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|This example unzips all files of an archive to the current directory:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:create|$entries as item(), $contents as item()*|xs:base64Binary}}<br />{{Func|archive:create|$entries as item(), $contents as item()*, $options as map(*)?|xs:base64Binary}}<br />
|-valign="top"
| '''Summary'''
|Creates a new archive from the specified entries and contents.<br/>The {{Code|$entries}} argument contains meta information required to create new entries. All items may either be of type {{Code|xs:string}}, representing the entry name, or {{Code|element(archive:entry)}}, containing the name as text node and additional, optional attributes:
* {{Code|format}}: allowed values are {{Code|zip}} and {{Code|gzip}}. {{Code|zip}} is the default.
* {{Code|algorithm}}: allowed values are {{Code|deflate}} and {{Code|stored}} (for the {{Code|zip}} format). {{Code|deflate}} is the default.
|-valign="top"
| '''Errors'''
|{{Error|number|#Errors}} the number of entries and contents differs.<br />{{Error|format|#Errors}} the specified option or its value is invalid or not supported.<br />{{Error|descriptor|#Errors}} entry descriptors contain invalid entry names, timestamps or compression levels.<br/>{{Error|encode|#Errors}} the specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if {{Option|CHECKSTRINGS}} is turned off.<br/>{{Error|single|#Errors}} the chosen archive format only allows single entries.<br />{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|The following one-liner creates an archive {{Code|archive.zip}} with one file {{Code|file.txt}}:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:update|$archive as xs:base64Binary, $entries as item()*, $contents as item()*|xs:base64Binary}}
|-valign="top"
| '''Summary'''
|Creates an updated version of the specified {{Code|$archive}} with new or replaced entries.<br/>The format of {{Code|$entries}} and {{Code|$contents}} is the same as for {{Function||archive:create}}.
|-valign="top"
| '''Errors'''
|{{Error|number|#Errors}} the number of entries and contents differs.<br />{{Error|descriptor|#Errors}} entry descriptors contain invalid entry names, timestamps, compression levels or encodings.<br/>{{Error|encode|#Errors}} the specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if {{Option|CHECKSTRINGS}} is turned off.<br />{{Error|modify|#Errors}} the entries of the given archive cannot be modified.<br/>{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|This example replaces texts in a Word document:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:delete|$archive as xs:base64Binary, $entries as item()*|xs:base64Binary}}
|-valign="top"
| '''Summary'''
|Deletes entries from an {{Code|$archive}}.<br/>The format of {{Code|$entries}} is the same as for {{Function||archive:create}}.
|-valign="top"
| '''Errors'''
|{{Error|modify|#Errors}} the entries of the given archive cannot be modified.<br/>{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|This example deletes all HTML files in an archive and creates a new file:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:create-from|$path as xs:string|xs:base64Binary}}<br/>{{Func|archive:create-from|$path as xs:string, $options as map(*)?|xs:base64Binary}}<br/>{{Func|archive:create-from|$path as xs:string, $options as map(*)?, $entries as item()*|xs:base64Binary}}
|-valign="top"
| '''Summary'''
|This convenience function creates an archive from all files in the specified directory {{Code|$path}}.<br/>The {{Code|$options}} parameter contains archiving options, and the files to be archived can be limited via {{Code|$entries}}. The format of the two last arguments is identical to {{Function||archive:create}}, but two additional options are available:
* {{Code|recursive}}: parse all files recursively (default: {{Code|true}}; ignored if entries are specified via the last argument).
* {{Code|root-dir}}: use name of supplied directory as archive root directory (default: {{Code|false}}).
|-valign="top"
| '''Errors'''
|{{Error|file:no-dir|File Module#Errors}} the specified path does not point to a directory.<br/>{{Error|file:is-dir|File Module#Errors}} one of the specified entries points to a directory.<br/>{{Error|file:not-found|File Module#Errors}} a specified entry does not exist.<br/>{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|This example writes the files of a user’s home directory to <code>archive.zip</code>:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:extract-to|$path as xs:string, $archive as xs:base64Binary|empty-sequence()}}<br/>{{Func|archive:extract-to|$path as xs:string, $archive as xs:base64Binary, $entries as item()*|empty-sequence()}}
|-valign="top"
| '''Summary'''
|This convenience function writes files of an {{Code|$archive}} directly to the specified directory {{Code|$path}}.<br/>The archive entries to be written can be restricted via {{Code|$entries}}. The format of the argument is the same as for {{Function||archive:create}} (attributes will be ignored).
|-valign="top"
| '''Errors'''
|{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|The following expression unzips all files of an archive to the current directory:
{| width='100%'
|-valign="top"
| width='120' | '''Signatures'''
|{{Func|archive:write|$path as xs:string, $entries as item(), $contents as item()*|xs:base64Binary}}<br />{{Func|archive:write|$path as xs:string, $entries as item(), $contents as item()*, $options as map(*)?|xs:base64Binary}}<br />
|-valign="top"
| '''Summary'''
|This convenience function creates a new archive from the specified {{Code|$entries}} and {{Code|$contents}} and writes it disk.<br/> See {{Function||archive:create}} for more details.
|-valign="top"
| '''Errors'''
|{{Error|number|#Errors}} the number of entries and contents differs.<br />{{Error|format|#Errors}} the specified option or its value is invalid or not supported.<br />{{Error|descriptor|#Errors}} entry descriptors contain invalid entry names, timestamps or compression levels.<br/>{{Error|encode|#Errors}} the specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if {{Option|CHECKSTRINGS}} is turned off.<br/>{{Error|single|#Errors}} the chosen archive format only allows single entries.<br />{{Error|error|#Errors}} archive creation failed.
|-valign="top"
| '''Examples'''
|All mp3 files from a directory are zipped and written to a file, along with an info file:
! width="110"|Code
|Description
|-valign="top"
|{{Code|descriptor}}
|Entry descriptors contain invalid entry names, timestamps or compression levels.
|-valign="top"
|{{Code|encode}}
|The specified encoding is invalid or not supported, or the string conversion failed. Invalid XML characters will be ignored if {{Option|CHECKSTRINGS}} is turned off.
|-valign="top"
|{{Code|error}}
| processing failed.
|-valign="top"
|{{Code|format}}
|The archive format or the specified option is invalid or not supported.
|-valign="top"
|{{Code|modify}}
|The entries of the given archive cannot be modified.
|-valign="top"
|{{Code|number}}
|The number of specified entries and contents differs.
|-valign="top"
|{{Code|single}}
|The chosen archive format only allows single entries.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu