exist
exist copied to clipboard
transform:transform() fails resolving nested includes when loading from disk
Describe the bug I want to run a (complicated) XSLT from disk. This XSLT has includes/imports, which in turn include/import others. All include file references are relative.
The first level of includes (the main file including other files) is without problems. But when an included file includes something eXist doesn't seem to be able to find this file.
Expected behavior I would like to run an XSLT from disk, with nested relative references to includes/imports, no matter how deep the include structure is.
To Reproduce Unzip this zip somewhere on your disk: test-xsl-from-disk.zip
Load this XQL in eXist and adjust the $href-xsl
variable so it points to the right location.
test-xslt-from-disk.zip
Run the XQL as admin. On my system I get the message:
Unable to set up transformer: net.sf.saxon.s9api.SaxonApiException: I/O error reported by XML parser processing file:/C:/eXist-db-5.3.0/test3.xsl: C:\eXist-db-5.3.0\test3.xsl (The system cannot find the file specified)
To check that a single level is ok: Adjust test-xsl-from-disk/include/test2.xsl
so it no longer includes test3.xsl
and comment out the call to named template test3
. Run the XQL again. All fine on my system.
Context (please always complete the following information):
- OS: Windows 10
- eXist-db version: 5.3.0 SNAPSHOT build 20210325222308
- Java Version 1.8.0_281
Additional context
- JAR installer
My guess at what's wrong: Somehow the base-uri information is not passed when including a file in XSLT from disk. Without a base-uri eXist (or the underlying Saxon) goes looking for something in the eXist installation directory C:/eXist-db-5.3.0
.
hmmm what would the base-uri be? 'xmldb:exist:///db' ?
I guess that would make all/many XQTS tests fail :-/
@xatapult what command did you issue for loading the xsl? I've seen different behavior in eXist when supplying a path to disk to the transform:transform
command from when you first load the XSL in a variable and then supply it to the transform:transform
command. I think the former works fine with imports.
@PieterLamers See the test-xslt-from-disk.zip as attached to this issue.
My guess would be that if you first load the XSL in a variable, relative imports will not work, because loading a document in a variable does not keep track of the base-uri of the document. But I might be wrong.