xsl-list
[Top] [All Lists]

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

2012-06-28 05:03:14

On 28-6-2012 11:46, Michael Kay wrote:
But base-uri($node) doesn't return the base URI of the stylesheet, it
returns the base URI of the specified node (which in common cases will
be the the URI of the document containing that node).

My bad. I often run stylesheets against themselves for the sake of
convenience when I don't require an input document. I should've
mentioned that in my first post and obviously, it won't work the minute
I change this practice.

To get the base URI of the current stylesheet module (or more
strictly, the base URI of the current expression in the stylesheet),
use the static-base-uri() function. (Different parts of a stylesheet
module can have different base URIs if you use xml:base, or if parts
of the stylesheet are contained in external entities).

I wasn't aware of the existence of that function (odd, considering we
implemented and tested it). But this looks like exactly what I needed.

There's no way to determine the base URI of the "currently executing
main stylesheet" unless you put a global variable in the principal
stylesheet module and bind it to static-base-uri() (and avoid using
xml:base or external entities, and ensure that the API via which the
stylesheet is loaded actually preserves the URI information...)

A lot of buts, but a workaround that could work in trivial
circumstances, thanks.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--