lschult2
lschult2

Reputation: 390

XSLT fn:transform() with stylesheet in eXist-db having xsl:import

I'm trying to use fn:transform() within a XSL stylesheet for the first time, where the stylesheet is stored in eXist-db:

transform(map{'stylesheet-location':'xmldb:exist:///db/sample.xsl', 'source-node':$xml})

sample.xml contains imports, e.g. <xsl:import href="functions.xsl"/>. It works when running the main XSL in oXygen. But when I run it in eXist-db, I get the following error:

exerr:ERROR Exception while transforming node: I/O error reported by XML parser processing file:/Applications/eXist-db.app/Contents/Resources/functions.xsl: /Applications/eXist-db.app/Contents/Resources/functions.xsl (No such file or directory) [at line 127, column 30]

So it looks like Saxon is looking for the imported XSL in the filesystem where the app is intalled, rather than in eXist-db, where sample.xsl is located. How can I get fn:transform() to call an XSL in eXist-db, and have the imports also come from eXist-db?

I tried adding 'stylesheet-base-uri':'xmldb:exist:///db/' to the map parameter of fn:transform(), but that did not resolve it.

Upvotes: 1

Views: 135

Answers (2)

Alan Paxton
Alan Paxton

Reputation: 26

Thanks for the pointer Norm, there is now a PR which I believe address the issue

https://github.com/eXist-db/exist/pull/4930

Upvotes: 0

Norm
Norm

Reputation: 1036

This is just a guess, but "xmldb:exist:" isn't a URI scheme that's defined outside of eXist. I imagine that whoever setup Saxon to run inside eXist configured some sort of URI resolver for Saxon that knows how to resolve that scheme and return data.

My further guess is that they failed to configure the module URI resolver in the same way. The fact that you get a file: URI instead of an error makes me wonder if the resolver that has been installed for "xmldb:exist:" scheme URIs is also failing to set the base URI of the returned resource correctly.

My final guess is that it works if you do it from Oxygen because Oxygen does configure both the entity and module URI resolvers.

I suspect your only recourse is to report this back to the folks who maintain the Saxon integration in eXist.

Upvotes: 1

Related Questions