Accessing file within repository or package
Thursday, 22 September 2016 · 2 messages
KS
Kendall Shaw22 Sep 2016 22:28 #
I have a module packaged as a XAR and installed in the repo. In xquery I want to load xslt. This did not work:
<package name="http://example.com/hellaworld"
abbrev="hella"
version="1.0.0"
spec="1.0"
xmlns="http://expath.org/ns/pkg">
<title>Hella world functions</title>
<dependency processor="basex"/>
<xslt>
<import-uri>http://example.com/hellaworld/hella.xsl</import-uri>
<file>hella.xsl</file>
</xslt>
<xquery>
<import-uri>http://example.com/hellaworld</import-uri>
<file>hella.xq</file>
</xquery>
</package>Then using the import-uri with doc, e.g.:
(: within hella.xq in the package :)
xslt:transform($some, doc(‘http://example.com/hellaworld/hella.xsl’))It does work, to use a path relative to the root of tomcat which I’m running basex in:
doc(‘webapps/basex/repo/http-example.com-hellaworld-1.0.0/hella/hella.xsl’)
but, I hope there is another way. How can I reference another file that is within the XAR package?
Kendall
KS
Kendall Shaw22 Sep 2016 22:41 #
Whoops. Never mind. It works to use a path relative to the xquery file: doc(‘hella.xsl’). That was not working earlier, presumably because of some unrelated problem.
Kendall
Quoted text · Kendall Shaw · 28 lines
From: <basex-talk-bounces at mailman.uni-konstanz.de> on behalf of Kendall Shaw <kendall.shaw at workday.com> Date: Thursday, September 22, 2016 at 1:28 PM To: BaseX <basex-talk at mailman.uni-konstanz.de> Subject: [basex-talk] Accessing file within repository or package I have a module packaged as a XAR and installed in the repo. In xquery I want to load xslt. This did not work: <package name="http://example.com/hellaworld" abbrev="hella" version="1.0.0" spec="1.0" xmlns="http://expath.org/ns/pkg"> <title>Hella world functions</title> <dependency processor="basex"/> <xslt> <import-uri>http://example.com/hellaworld/hella.xsl</import-uri> <file>hella.xsl</file> </xslt> <xquery> <import-uri>http://example.com/hellaworld</import-uri> <file>hella.xq</file> </xquery> </package> Then using the import-uri with doc, e.g.: (: within hella.xq in the package :) xslt:transform($some, doc(‘http://example.com/hellaworld/hella.xsl’)) It does work, to use a path relative to the root of tomcat which I’m running basex in: doc(‘webapps/basex/repo/http-example.com-hellaworld-1.0.0/hella/hella.xsl’) but, I hope there is another way. How can I reference another file that is within the XAR package? Kendall
Written for BaseX 8.5. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery