How can I retrieve the XML source file name using XSL 1.0 code?
相关问题
- Illegal to have multiple roots (start tag in epilo
- Newtonsoft DeserializeXNode expands internal array
- how to use special characters like '<'
- XML - XSLT - document() function inside count() fu
- convert logback.xml to log4j.properties
相关文章
- Creating XML Elements without namespace declaratio
- Get Attribute Value From Simple XML Using JQuery /
- Directly signing an Office Word document using XML
- When sending XML to JMS should I use TextMessage o
- Fragment Content Overlaps Toolbar and Bottom Navig
- Getting “Error: Missing Constraints in ConstraintL
- xslt localization
- Upgrading transaction.commit_manually() to Django
I know this is old, but other people may still come upon this in looking for an answer.
The only way I know of to do this in XSLT 1.0 is to use a script function inside the XSLT:
This will generate an XML output such as:
In this case, I used a file named
C:/XLST/My Test XML File.txt
.The
vb.net
code used for importing text files first converts that file into XML and appends the.xml
extension to the source filename, and is then processed by the Transform.This is why my filename ends in
.txt.xml
Normal XLST string functions can then be used as needed to replace the
%20
with' '
and perhaps only return the filename part and not the entire path and filename.There is no way to obtain the name or path of the file being transformed by XSL. Due to the nature of XSL, the data being transformed might not be from a file, it might just be transforming a stream of data.
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.
With Xalan there is the following, non-official function :
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
.