Is it possible to set the root for resolving include and import in xslt:transform
Wednesday, 25 July 2018 · 3 messages · last reply 28 Jul 2018
OS
Omar Siam25 Jul 2018 15:44 #
Hi list!
I have an XSL snippet that includes and imports some XSL files.
I pass this to
xslt:transform and the includes and imports are resolved using the working directory where basex was started from.
On my server that was / and on my Windows development machine C:\Users\user\basex\bin. This was not what I expected.
Quick way to see the effect:declare namespace xsl="http://www.w3.org/1999/XSL/Transform";
xslt:transform(<root><test/></root>,
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:template match="test"><root><xsl:value-of
select="static-base-uri()"/></root></xsl:template>
</xsl:stylesheet>)Perhaps in a future version it may be possible to set that to the directory the XQuery runs from or to be able to just specify what it should be.
Best regards
Omar Siam
CG
Christian Grün28 Jul 2018 14:45 #
Hi Omar,
As the XSLT transformer is not part of the BaseX code, we may need to find out if we can set the base URI to the generated transformer instance [1]. Maybe a custom URI resolver could be assigned? Suggestions are welcome.
Best,
Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-core/src/main/java/org/basex/query/func/xslt/XsltTransform.java
Quoted text · Omar Siam · 32 lines
On Wed, Jul 25, 2018 at 3:44 PM Omar Siam <Omar.Siam at oeaw.ac.at> wrote: > > Hi list! > > I have an XSL snippet that includes and imports some XSL files. > > I pass this to xslt:transform and the includes and imports are resolved > using the working directory where basex was started from. > > On my server that was / and on my Windows development machine > C:\Users\user\basex\bin. This was not what I expected. > > Quick way to see the effect: > > declare namespace xsl="http://www.w3.org/1999/XSL/Transform"; > > xslt:transform(<root><test/></root>, > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="2.0"> > <xsl:template match="test"><root><xsl:value-of > select="static-base-uri()"/></root></xsl:template> > </xsl:stylesheet>) > > Perhaps in a future version it may be possible to set that to the > directory the XQuery runs from or to be able to just specify what it > should be. > > Best regards > > Omar Siam > >
MH
Quoted text · Omar Siam · 23 lines
On 25.07.2018 15:44, Omar Siam wrote: > I have an XSL snippet that includes and imports some XSL files. > > I pass this to xslt:transform and the includes and imports are resolved > using the working directory where basex was started from. > > On my server that was / and on my Windows development machine > C:\Users\user\basex\bin. This was not what I expected. > > Quick way to see the effect: > > declare namespace xsl="http://www.w3.org/1999/XSL/Transform"; > > xslt:transform(<root><test/></root>, > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="2.0"> > <xsl:template match="test"><root><xsl:value-of > select="static-base-uri()"/></root></xsl:template> > </xsl:stylesheet>) > > Perhaps in a future version it may be possible to set that to the > directory the XQuery runs from or to be able to just specify what it > should be.
Can't you "just specify what it should be" by putting the base URI you want into
<xsl:stylesheet xml:base="file:///C:/dir/subdir"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0"> ... </xsl:stylesheet>or perhaps picking up that static base URI from XQuery with
xslt:transform(<root><test/></root>,
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xml:base="{static-base-uri()}"
version="2.0">
<xsl:template match="test"><root><xsl:value-of
select="static-base-uri()"/></root></xsl:template>
</xsl:stylesheet>)? I am not sure that is what you want but I am also not sure whether you have considered it.
Written for BaseX 9.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery