How can I get the file name using xsl 1.0?
I tried
<xsl:value-of select="base-uri()" />
but got "Fatal Error! Could not find function: base-uri"
How can I get the file name using xsl 1.0?
I tried
<xsl:value-of select="base-uri()" />
but got "Fatal Error! Could not find function: base-uri"
There is no such XPath function, or XSLT extension to XPath function to do this.
IT is quite possible for there to be no file, and even if there is no reason for the XSLT engine to have that file name (consider loading the file content into a buffer, parsing the buffer into a DOM and then passing the DOM to the XSLT processor).
You will need to pass the filename into the processor to be available as a parameter in the transform.
base-uri()
is a standard XPath 2.0 function, so when running XSLT 1.0 this function will be unavailable.
In XSLT 1.0 the filename (of what?) may be passed as a parameter for the transformation.
Do note that it isn't always possible to produce a filename for a stylesheet or for an XML document -- either or both may be residing in memory without an associated file.
It is not clear from the problem which filename must be produced.
Here is how to find filenames in XPath 2.0 / XSLT 2.0:
The filename of the current document:
base-uri()
The filename of the current stylesheet module:
base-uri(document(''))