ZIPxmlzipio

A zip file handler for libxml2

xmlzipio adds support for reading and writing files inside ziparchives to libxml2.

It is based on the minizip and miniunzip examples provided with zlib.


Files (and their license)

xmlzipio.h
xmlzipio.c

The interface for xmlzipio and it's implementation. xmlzipio.c/.h are published under the terms of the MIT License.

zip.h
zip.c
unzip.h
unzip.c

Files taken from minizip and miniunzip to deal with the zip archives. zip.c/.h and unzip.c/.h are published under the terms of zlib/libpng license.

Makefile.am

Example Makefile shows how to integrate xmlzipio into your project using libtool and automake.

README
LICENSE
schraubstock.jpg
xmlzipio.html

And a small doku.


Usage

Download the files and add them to your project. (If you use automake you can just use the Makefile.am to create a libxmlzipio.la)

Include xmlzipio.h. Than call xmlZipRegisterInputCallback() and xmlZipRegisterOutputCallback(). Now you can call for example xmlParseFile(XMLFileName) to parse an xml file. The filename must be of the form zip:zipname!filename (i.e. zip:web.zip!/xml/index.xml). Note that filename must be an absolute path, that means it must begin with "/".

This syntax is inspired by that discribed at http://jakarta.apache.org/commons/sandbox/vfs/filesystems.html#Zip%20and%20Jar. The idea is, that you can use zip with any uri supported by libxml. By now, only local paths and file uris are supported (see Limitations).

Example:
xmlDocPtr doc;

xmlKeepBlanksDefault(0);
xmlRegisterDefaultInputCallbacks();
xmlRegisterDefaultOutputCallbacks();
xmlZipRegisterInputCallback();
xmlZipRegisterOutputCallback(); // it's importend to xmlzipio after the default handlers, so xmlzipio is asked first.

doc = xmlParseFile("test.zip#zip:text.xml");
...
xmlSaveFormatFileEnc ("test.zip#zip:text.xml", doc, "UTF-8", 0);

xmlFreeDoc(doc);
xmlCleanupParser();

Limitations

Currently only local paths and file uris are supported

local paths: zip:../dir/somefile.zip!/file.xml
and file uris: zip:file:///home/user/dir/somefile.zip!/file.xml

The next step would be to use xmlIO again to access the archive. This would give us the posibility to read files from the web or use nested zip archives

zip:http://domain.org/somefile.zip!/file.xml
zip:zip:file:///home/user/dir/somefile.zip!/files.zip!/content.xml

Interface

int xmlCompressionLevel (int c)

Change the CopressionLevel for the zip archive.

c: the new compression level (0..9). 0 for deflated.
Returns: the old compression level.
int xmlZipRegisterInputCallback ()

Register the Callbacks to add read zip archives.

int xmlZipRegisterOutputCallback ()

Register the Callbacks to add write zip archives.


Download

xmlzipio.tar.gz

incorporated changes in the naming scheme (Thu Oct 30)

xmlzipio-0.1.tar.gz

initial release (Wed Oct 29)


Last modified: Thu Oct 30 17:39:39 CET 2003