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.


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 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.


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="" xmlns:b="" xmlns:zip="" xmlns:onion="" 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="" />