The information is not available in XSLT 1.0 except (a) by using vendor extensions, or (b) by passing the information to the stylesheet as a parameter.
In XSLT 2.0 you can use the static-base-uri()
function.
There are some complications if you use a processor like Saxon-EE that allows you to deploy a compiled stylesheet; in that situation the spec doesn't define clearly whether static-base-uri()
gives you the location of the source code or the location of the compiled code. Moreover, it's possible that neither is actually available, perhaps for security reasons. So this is all a little bit system-dependent.
Note also that the static-base-uri()
will change depending which stylesheet module you are in, and the rules if you use xml:base
or XInclude
or external entities get even more complicated...