简体   繁体   English

如何在XSLT 2.0中获取当前xml文件名?

[英]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. 我将一种XML转换为html,并使用document-uri()获取当前文件名。 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. 当我在本地系统上进行转换时,此代码运行良好,但是当我尝试在服务器和应用程序上进行转换时,使用java时,此代码未返回任何值。

XSLT CODE: XSLT代码:

<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. 如果document-uri(。)不返回任何内容,则表明存储文档的URI未知。 This probably means that the document was in memory when passed to the XSLT processor, for example: 这可能意味着文档在传递到XSLT处理器时位于内存中,例如:

  • you may have passed a StreamSource with no system ID property 您可能已经传递了没有系统ID属性的StreamSource

  • you may have passed a DOM Document 您可能已经通过了DOM文档

So we need to see how the XSLT transformation was invoked. 因此,我们需要了解如何调用XSLT转换。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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