http://onionworks.net/2004/renderengine/web

response (expires : int, [filename : string], [dispositionType : string]) : void

The method “response” makes it possible to send binary data.

The first example shows how data can be sent from elements.

<xsl:stylesheet xmlns:web="http://onionworks.net/2004/renderengine/web" xmlns:b="http://onionworks.net/2004/renderengine/binary" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:onion="http://onionworks.net/2004/data" version="1.0">
<xsl:template match="/">
<xsl:value-of select="b:write(image)" />
<b:output mimeType="{image/@onion:mimeType}">
<web:response expires="60" />
</b:output>
</xsl:template>
</xsl:stylesheet>
Sending graphic from onion resource

In the example, the XML data for the graphic is sent as a first step and then the binary data is sent via “b: output”. The mimetype is determined here from the element itself.

Data can also be sent from the file system however. The second example shows how this works.

<xsl:stylesheet xmlns:web="http://onionworks.net/2004/renderengine/web" xmlns:b="http://onionworks.net/2004/renderengine/binary" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:onion="http://onionworks.net/2004/data" version="1.0">
<xsl:template match="/">
<xsl:value-of select="b.writeText('')" />
<b:output mimeType="text/plain">
<web:response expires="0" dispositionType="attachment" filename="datei.txt" />
</b:output>
</xsl:template>
</xsl:stylesheet>
Sending file from file system

In the second example, a file is sent from the file system.

An XML stream must be sent first of all in order for the sending of the file to work.

The parameter “dispositionType” should be specified. “inline” is defined as the default value. Browsers can have problems with this value however.
A further value would be “attachment” in order to provide the user with the option "display" or "save".