简体   繁体   中英

How to get current xml file name in XSLT 2.0?

I am transforming one XML to html and using document-uri() to get current filename. This code is working fine when i am transforming on my local system but with java when i try to transform on server and application it is not returning any value.

XSLT CODE:

<xsl:value-of select="substring-before(replace(document-uri(.), '.*/', '') , '.xml')"/>

尝试这个:

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

If document-uri(.) returns nothing, this suggests that the URI where the document is stored is unknown. This probably means that the document was in memory when passed to the XSLT processor, for example:

  • you may have passed a StreamSource with no system ID property

  • you may have passed a DOM Document

So we need to see how the XSLT transformation was invoked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM