http://onion.net/2010/compression/zip

create (level : number) : void

A new. zip binary stream can be produced with the method »create()«.

Parameter

The parameter »level« indicates the degree of compression here. This is represented by a number between 0 and 10.

The choice of the compression degree should be made conditional on the contents of the .zip file. If mainly .jpeg pictures are to be zipped, a compression level of 0 makes good sense since the files are already compressed. Further compression could have a negative effect on the quality.

Usage

Usually, an empty .zip binary stream is created first with »create()«. This is then filled gradually with contents. The binary stream is then completed with the method »finish()«, meaning the file can be produced via a <b:output /> element.

Example

The following example produces an empty .zip file.

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:b="http://onionworks.net/2004/renderengine/binary" xmlns:zip="http://onion.net/2010/compression/zip" xmlns:onion="http://onionworks.net/2004/data" version="1.0">
<xsl:template match="/">
<xsl:variable name="zip" select="zip:create(0, 'off')" />
<xsl:value-of select="zip:finish()" />
<b:output mimeType="application/zip">
<b:webResponse dispositionType="attachment" filename="test.zip" />
</b:output>
</xsl:template>
</xsl:stylesheet>

See also