Database Reference
In-Depth Information
compression
Description
Handling of ZIP, GZIP, and TAR files
Namespace
compression="http://exist-db.org/xquery/compression"
Type/default status
Java; enabled in $EXIST_HOME/conf.xml ; enabled in $EXIST_HOME/extensions/
build.properties
Class
org.exist.xquery.modules.compression.CompressionModule
This module allows you to create and read ZIP, GZIP, and TAR compressed files.
Let's take a ZIP file as example (GZIP and TAR work likewise). You can create a ZIP
file by calling compression:zip and feeding it a sequence of items to compress:
• If such an item is of type xs:anyURI , it is supposed to be the URI of a resource or
a collection. A collection is zipped in its entirety and its directory structure is
mimicked in the ZIP file.
• If it's an entry element, its content is zipped. It takes three attributes:
— The name attribute is used as the path of the resource in the ZIP file.
— The type attribute tells the module how to interpret the contents of the entry
element. Possible values are collection , uri , binary , xml , and text .
— The optional method attribute tells the module whether the resource should be
compressed before being added to the ZIP file (the default) or simply stored
as is. (The latter is useful when, for instance, creating ebook files in ePub for‐
mat, which requires a noncompressed Internet media type file.)
Here is an example that zips a part of the topic's examples and adds an extra XML
file:
let $ stuff-to-compress as item () + := (
xs:anyURI ( '/db/eXist-book/getting-started' ),
<entry name = " EXTRA/x.xml " type = " xml " >
<Extra> Some extra stuff... </Extra>
</entry>
)
let $ file-uri := '/some/path/on/your/disk/out.zip'
let $ zipfile := compression:zip ( $ stuff-to-compress , true ())
return
file:serialize-binary ( $ zipfile , $ file-uri )
 
Search WWH ::




Custom Search