Re: [xsl] Referring to stylesheet itself, possible in XSLT 1.0, but how in XSLT 2.0?

Subject: Re: [xsl] Referring to stylesheet itself, possible in XSLT 1.0, but how in XSLT 2.0?
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Tue, 17 Oct 2006 09:27:02 +0100
On 10/17/06, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
Hi List,

I want to retrieve the name of the xslt file that is currently
processing something for purposes of logging and tracing.

In XSLT 1.0 you could do document('') to retrieve the xslt stylesheet
document itself, and as a result you could do some funny  things
transforming oneself. In XSLT 2.0, there is resolve-uri() and
document-uri(), the second of which takes a document or node as
reference, but it is not possible to use document('') (with empty
string) to refer to the current xslt file, it will throw an error. Is
there a way to get the current xslt file with XSLT 2.0?

What error is being thrown? Saying "it doesnt work" or "it throws an error" is pretty unhelpful without the associated error.

document-uri(document(''))

...should be fine.  How are you running the transform?  If you are
loading the stylesheet as a stream then its uri will be lost, in which
case call setSystemId() on the Source.

cheers
andrew

Current Thread