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

addBinary (filename : string, xlink : string, [fromDataSource : boolean]) : void

Using the method »addBinary()«, binary files such as pictures or pdf files located in the system can be added to the .zip stream.

Parameter

The complete file name is transferred to the parameter »filename« complete with file extension, just as it shall be contained in the .zip later on.

The XLink to the binary method that produces the binary file must be transferred to the parameter »xlink«. If the binary file is read directly from the data source, then the XLink can only consist of the onion.net ID.

»fromDataSource« can be specified as a last parameter in order to control whether the binary file is produced from the data source. If the link to an external binary method was transferred to the parameter »xlink«, then »fromDataSource« must receive the value »false()«.The value »true()« is implicitly set.

Beispiel

The following example produces an empty .zip binary stream, adds a PDF file which is not read from the data source 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:addBinary('document.pdf', c.xlink('pdf'), false())" />
<xsl:value-of select="zip:finish()" />
<b:output mimeType="application/zip">
<b:webResponse dispositionType="attachment" filename="test.zip" />
</b:output>
</xsl:template>
</xsl:stylesheet>