declare %output:method("text")
%output:encoding("cp1252")
%rest:path("/util/download/text-cp1252")
%rest:form-param("text", "{$text}", "")
%rest:form-param("file-name", "{$fileName}", "text.txt")
function f:downloadTextCp1252(
$text as xs:string,
$fileName as xs:string) {
let $text := replace($text, '
', '
')
return (
<rest:response>
<http:response status="200">
<http:header name="Content-Disposition" value='attachment; filename="{$fileName}"'/>
<http:header name="Content-Language" value="en"/>
<http:header name="Content-Type" value="text/csv; charset=cp1252"/>
</http:response>
</rest:response>,
$text
)
};
PS: The <http:header> seems to be without effect - experiments seemd to show that I have to use the %output declaration.