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

addLiteral (filename : string, xlink : string, encoding : string) : void

The method »addLiteral()« can be used to add a text file to the .zip. Text file just means here a file produced by means of a literal method, unlike a binary file, which is produced using a binary method.

Examples of text files are files with the endings .txt or .csv. HTML or CSS files can also be produced in this way.

Parameter

The name under which the file is to be listed in the .zip later on is to be transferred to the first parameter »filename«.

An XLink to the literal method, which produces the file, is transferred to the parameter »xlink«.

The encoding of the later text file is transferred to the parameter »encoding«.

Example

The following example produces an empty .zip binary stream, adds a .csv file, and lastly produces the .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:variable name="addItem" select="zip:addLiteral('empfänger.csv', c.xlink('collectRecipients'), 'ISO-8859-15')" />
<xsl:value-of select="zip:finish()" />
<b:output mimeType="application/zip">
<b:webResponse dispositionType="attachment" filename="test.zip" />
</b:output>
</xsl:template>
</xsl:stylesheet>

It is to be noted that the method specified in the XLink may have no more than the access protection »protected«.