Hi Tim,
file:write uses the default W3 serialization method "XML". This means that the standard entities (&, <, etc.) will be encoded. This can be circumvented by using the 'text' output method…
file:write(..., ..., map { 'method': 'text' })
…or file:write-text.
In BaseX, we introduced our own serialization method 'basex', which serializes strings as strings and basex64 and hex data as bytes. With this method (if it had been part of the official standard), file:write-text and file:write-binary could actually have been dropped.
Ah, never mind. When I run the file:write-text() without jobs:eval(), I get an error, "Cannot convert xs:dateTime to xs:string." Is it possible to return the error from a job call?
You can cache the result of a query…
let $job-id := jobs:eval(..., ..., map { 'cache': true() })
…and retrieve the result or the error with jobs:result($job-id).
Hope this helps, Christian