Custom URI resolver
Saturday, 25 July 2015 · 2 messages · last reply 28 Jul 2015
MG
Max Goltzsche25 Jul 2015 22:00 #
Hello,
I want to import a XSL transformation into another by name as it is already possible with XQuery modules - a pitty that this doesn't work with XSL transformations imported via expath package.
Furthermore I want to restrict file system access in XSL transformations and xqueries.
As far as I understand it to do both I need to define a custom URI resolver - Please tell me if there is a better way.
Thus my question is: How can I register a central URI resolver to be used by both XSLT and XQuery?
I work with BaseX 8.2.3 and Saxon-HE 9.6.0-6 directly with Context and LocalSession objects in Java.
I've read http://docs.basex.org/wiki/Catalog_Resolver and registered a catalog file via SET CATFILE but it doesn't seem to be used in XSL transformations. I've also tried it with Apache XML resolver in the classpath. For Saxon I tried to register the CatalogResolver explicitly by setting the system property
http://saxon.sf.net/feature/uriResolverClass to
org.apache.xml.resolver.tools.CatalogResolver and writing a
CatalogManager.properties file without effect.
What is missing? Please help!
Best regards,
Max
CG
Christian Grün28 Jul 2015 12:52 #
Hi Max,
Sorry for letting you wait.
Quoted text · Max Goltzsche · 2 lines
> Thus my question is: How can I register a central URI resolver to be used by > both XSLT and XQuery?
There is currently no way to do so, mostly because BaseX and Saxon are simply too different to get this working.
Quoted text · Max Goltzsche · 3 lines
> I've read http://docs.basex.org/wiki/Catalog_Resolver and registered a > catalog file via SET CATFILE but it doesn't seem to be used in XSL > transformations.
True, this only applies to documents that are added to a database.
Quoted text · Max Goltzsche · 5 lines
> I've also tried it with Apache XML resolver in the > classpath. For Saxon I tried to register the CatalogResolver explicitly by > setting the system property http://saxon.sf.net/feature/uriResolverClass to > org.apache.xml.resolver.tools.CatalogResolver and writing a > CatalogManager.properties file without effect.
Our XSLT Module allows you to specify both the input and stylesheet as a file path, string or XML node [1]. Which option did you go for/have you experimented with all options?
The Java class XsltTransform.java [2] illustrates how the XSLT transformation is currently performed in BaseX. If you are interested, you could try to build a simple, self-contained Java class that transforms your input with Saxon, and we could then integrate the missing pieces in our software.
What do you think?
Christian
[1] http://docs.basex.org/wiki/Xslt_Module
[2] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/func/xslt/XsltTransform.java
Written for BaseX 8.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery