Retrieve XML file name using XSLT

前端 未结 4 1293
轮回少年
轮回少年 2021-01-14 05:01

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

4条回答
  •  一向
    一向 (楼主)
    2021-01-14 05:31

    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:

    
    
    file:///C:/XLST/My%20Test%20XML%20File.txt.xml
    
    

    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.

提交回复
热议问题