Archive Module: Sixth Proposal

From Spex: Specifications for XQuery Modules
Jump to: navigation, search

Yet another proposal for the Archive Module:

  • renamed from ZIP to Archive

The full function signatures are as follows:

(: Module namespace is still subject to change. :)
module namespace archive = "http://www.expath.org/ns/archive";

(:~
 : Create a new archive according to the given spec.
 : The contents can be string and base64Binary items.
 :
 : Example:
 : <!-- specify compression level (0 = uncompressed) -->
 : <entry last-modified="" compression-level="0">
 :   myfile.txt
 : </entry>
 : <!-- specify encoding for text entries -->
 : <entry encoding="Shift_JIS">
 :   dir/myfile.xml
 : </entry>
 : <entry>
 :   dir/dir2/image.png
 : </entry>
 :
 : @return a base64Binary 
 :
 : @error if the number of entry elements differs from the number
 :        of specified contents: count($entries) ne count($contents)
 : @error if an encoding is specified and the item is a base64Binary
 :)
declare function archive:create($entries as element(entry)*, $contents as item()*)
    as xs:base64Binary external;

(:~
 : Return the specification of the given archive.
 :
 : Example:
 : <entry last-modified="2009-03-20T03:30:32" compressed-size="232" uncompressed-size"324" encrypted="false">
 :   myfile.txt
 : </entry>
 : <entry>
 :   dir/myfile.xml
 : </entry>
 : <entry>
 :   dir/dir2/image.png
 : </entry>
 :
 : @return specification
 :)
declare function archive:entries($archive as xs:base64Binary)
    as element(entry)* external;

(:~
 : Returns all entries from the archive as a string.
 : The default encoding used to read the string is UTF-8.
 :
 : @return strings
 :
 : @error if the file contains invalid utf-8 characters
 : @error if the file doesn't exist
 :)
declare function archive:extract-text($archive as xs:base64Binary)
    as xs:string* external;

(:~
 : Returns the entries identified by the given paths from the archive
 : as a string.
 : The default encoding used to read the string is UTF-8.
 :
 : @return strings
 :
 : @error if the file contains invalid utf-8 characters
 : @error if the file doesn't exist
 :)
declare function archive:extract-text($archive as xs:base64Binary, $entry-names as xs:string*)
    as xs:string* external;

(:~
 : Returns the entries identified by the given paths from the archive
 : as a string.
 :
 : @return strings
 :
 : @error if the file contains invalid characters
 : @error if a transcoding error happens
 :)
declare function archive:extract-text($archive as xs:base64Binary, $entry-names as xs:string*, $encoding as xs:string)
    as xs:string* external;

(:~
 : Returns all entries from the archive
 : as base64Binary.
 :
 : @return base64Binary items
 :
 : @error if the file does not exist
 :)
declare function archive:extract-binary($archive as xs:base64Binary)
    as xs:base64Binary* external;

(:~
 : Returns the entries identified by the given paths from the archive
 : as base64Binary.
 :
 : @return base64Binary items
 :
 : @error if the file does not exist
 :)
declare function archive:extract-binary($archive as xs:base64Binary, $entry-names as xs:string*)
    as xs:base64Binary* external;

(:~
 : Adds and replaces entries in a archive according to
 : the given spec. The contents can be string and base64Binary items.
 :
 : @return the updated base64Binary
 :
 : @error if the number of entry elements differs from the number
 :        of specified contents: count($entries) ne count($contents)
 :
 :)
declare function archive:update($archive as xs:base64Binary, $entries as element(entry)*, $contents as item()*)
    as xs:base64Binary external;

(:~
 : Deletes entries from a archive.
 :
 : @return the updated base64Binary
 :
 : @error if an addressed entry does not exist
 :)
declare function archive:delete($archive as xs:base64Binary, $entry-names as xs:string*)
    as xs:base64Binary external;
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox