Hi Jos,
While the ZIP Module is still part of our distribution, it’s not actively maintained anymore, and we generally recommend our users to switch to the Archive Module [1]. Providing custom compression levels for each archive entry is one of the features that is provided by this newer module.
Hope this helps, Christian
[1] https://docs.basex.org/wiki/Archive_Module
On Tue, Sep 8, 2020 at 9:29 AM Jos van den Oever jos@vandenoever.info wrote:
Hello all,
As you might know, epub files and ODF files are zip files with specific contents. BaseX supports the expath zip module and could in theory be used for creating these files if it were not for a missing simple feature.
There is one rule for epub and ODF files that cannot be followed by BaseX at the moment: the first file in the zip container should be named 'mimetype' and is a plain test file that contains the mimetype string. This is meant to allow applications to read the mimetype at a fixed offset in the file and without doing decompression.
In unzip -vl it looks like this:
Length Method Size Cmpr Date Time CRC-32 Name
20 Stored 20 0% 10-14-2018 05:57 2cab616f mimetype
Here is an XQuery to create a file with just that entry:
declare namespace zip = "http://expath.org/ns/zip"; let $zip := <zip:file href="new.epub"> <zip:entry name="mimetype" compressed="no" method="text"> {"application/epub+zip"} </zip:entry> </zip:file> return zip:zip-file($zip) ``` BaseX does not support the 'compressed' option. Without that option the file 'mimetype' is stored in compressed form and cannot be used by applications to quickly determine the mimetype of the file. Modifying the xml in an exisiting epub or ODF with zip:update-entries is also not possible because the mimetype file is still compressed. An additional issue: when reading a zip file, the entries in <zip:file> are not in the same order as they are in the zip file. So when modifying an existing file, the mimetype entry has to moved to the front of the list explicitly. In short: to make BaseX support the creation of epub en ODF files it should: - support the 'compressed' attribute - retain the order of files in the zip file in the <zip:file> element. Best regards, Jos