Dear Oliver,
Here I used doc() and referred to the additional documents, e.g. doc(‘/serials/serial-123.xml’). Unfortunately, the transformation says that the file or directory does not exist.
If this function call is located in the XSLT file, it’s exactly what you have already guessed: Saxon won’t be able to resolve this file against the database.
Checked that simple with a browser – worked. The transformation instead didn’t work – it returned a 401 unauthorized http response.
I assume this is due to the way how Saxon evaluates the fn:doc function. Authorization information in URLs is ignored by the standard URL connections in Java, and my guess is that Saxon is based on these connections (in BaseX, we tackle this by enriching the connections with the given authorization data; but I know this won’t help you here).
Here are a few approaches how to solve the issue:
1. Use the REST API of BaseX with default admin privileges (by adding a context parameter with 'org.basex.user' in the web.xml file [1], and restarting BaseX). This should only be done if your XQuery expression does not perform any updates (otherwise, you will run into a deadlock), and (quite obviously) if there are no security concerns.
2. Temporarily write database files to disk, and delete them after the transformation. This may sound a bit cumbersome, but it may be the fastest solution (if performance is critical), because no time will be spent for retrieving files via HTTP.
3. Ask Michael Kay/Saxon if there is a chance to make fn:doc aware of authorization info.
Hope this helps, all the best from Konstanz, Christian