Re: [xsl] Input Filenames available to the parser?

Subject: Re: [xsl] Input Filenames available to the parser?
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Wed, 4 Jan 2006 22:30:41 +0000
On 1/4/06, Agnisys <agnisys@xxxxxxxxx> wrote:
> Hi,
>   (Using Saxon8B, XSLT 2.0)
>   Is the name of the input XML file and the XSLT file available to the
parser? If not, how can the
> following be done?
>
> For example:
> If input is "in.xml" being processed by "xform.xsl", I want the generated
output to list the two
> files as ...
>
> :
> //Input XML   : in.xml
> //Transformer : xform.xsl

You can use the base-uri() function to return the uri of the tree
containing the context node, so to get the input filename use:

//Input XML :<xsl:value-of select="tokenize(base-uri(/), '/')[last()]"/>

To get the stylesheet filename you could use base-uri(document(''))
but do you really need to discover it... couldn't you just hard code
it in as you decide the name when you do file -> save :)

By the way, there was a change between Saxon 8.6 and 8.6.1 where
document-uri() became base-uri() (I think anyway, I had to make the
change, maybe Mike will confirm) so it's worth getting the very latest
version.

cheers
andrew

Current Thread