[xsl] Getting the current document from an xsl:function

Subject: [xsl] Getting the current document from an xsl:function
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 28 Jun 2012 11:01:04 +0200
Hi List,

It's been a while ;). However, today I was wondering about the
following: the function base-uri() returns the uri of the current xsl
document by default, when no context is given. But since there is no
context in xsl:function, this won't work automatically from a function,
instead I need to do something like:

<xsl:function name="my:current-dir" as="xs:string">
    <xsl:param name="context" as="node()" />
    <xsl:value-of select="replace(base-uri($context), '/[^/]+$', '')" />
</xsl:function>

Does anyone know a way to remove the constraint of passing on a context
item? The reaon I ask is that I'd like to be able to find the current
dir from places where there is no context. But, as far as I know, this
is currently not possible in XSLT 2.0.

Thanks,
Abel

Current Thread