Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve XML file name using XSLT

Tags:

xml

xslt

How can I retrieve the XML source file name using XSL 1.0 code?

like image 229
Andrey Bushman Avatar asked May 23 '26 04:05

Andrey Bushman


2 Answers

In XSLT 2.0, there are two relevant functions: base-uri() and document-uri().

In XSLT 1.0, you have to pass the URL or filename as a parameter to the stylesheet, unless the processor offers extension functions for the purpose.

like image 90
Michael Kay Avatar answered May 26 '26 00:05

Michael Kay


With Xalan there is the following, non-official function :

<xsl:value-of select="document-location()"/>

I use it on a transformation of a local file and it gives me the absolute path of the XML file being transformed. I found that function browsing the Xalan code, it is part of the class FuncDoclocation.

like image 40
nico Avatar answered May 25 '26 23:05

nico