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.
我正在将一个XML转换为html并使用document-uri()来获取当前文件名。当我在我的本地系统上进行转换时,此代码工作正常但是当我尝试在服务器和应用程序上进行转换时,它没有返回任何值。
XSLT CODE:
<xsl:value-of select="substring-before(replace(document-uri(.), '.*/', '') , '.xml')"/>
2 个解决方案
#1
1
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:
如果document-uri(。)不返回任何内容,则表明存储文档的URI未知。这可能意味着文档在传递给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转换。
#2
1
Try this:
<xsl:value-of select="tokenize(base-uri(.), '/')[last()]"/>
#1
1
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:
如果document-uri(。)不返回任何内容,则表明存储文档的URI未知。这可能意味着文档在传递给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转换。
#2
1
Try this:
<xsl:value-of select="tokenize(base-uri(.), '/')[last()]"/>