Reputation: 884
I have just realized my logger is very active in the case of a function responsible for generating epubs. The problem is it works as expected. Hence I wonder what is going on here.
The error:
java:org.exist.xquery.XPathException, exerr:ERROR The actual return type does not match the sequence type declared in the function's signature: epub-util:render-epub(node()+, xs:string) xs:base64Binary. Expected cardinality: exactly one, got 0.
… epub is properly served to the client.
As for exerr:ERROR
, I checked the general log in $EXIST_HOME/webapp/WEB-INF/logs/exist.log
. There are no associated errors caught.
The suspected function:
declare function epub-util:render-epub($entries as node()+, $name as xs:string) as xs:base64Binary {
let $zip-file := compression:zip($entries, true())
let $archiveName := $name
return
response:stream-binary($zip-file, 'application/epub+zip', lower-case(replace($archiveName, ' ', '-')) || '.epub')
};
I run eXist on Ubuntu Server 14.04, eXist-db is 3.0.RC1.
Upvotes: 0
Views: 163
Reputation: 656
response:stream-binary()
is a very special function, that in essence directly writes bytes to a servlet output stream , hence it can only be used in the REST interface.
It can only write a byte stream to a HTTP agent, that is e.g. your web browser. It is not possible to store this data in a variable.
I agree that even item()
is not a good thing, it should be something like void
but that does not exist.
The common use-case it to have this expression as the last function call in a xquery script. A similar construct we use in the JFreechart library.
Upvotes: 2
Reputation: 5294
According to the eXist-db function documentation for response:stream-binary()
, this function returns item()
, not xs:base64binary
. Replacing the return type with item()
should fix the error.
Upvotes: 2