使用xsl获取文件名

发布于 2024-07-13 17:08:25 字数 161 浏览 4 评论 0原文

如何使用 xsl 1.0 获取文件名?

我尝试过

<xsl:value-of select="base-uri()" />

,但得到“致命错误!找不到函数:base-uri”

How can I get the file name using xsl 1.0?

I tried

<xsl:value-of select="base-uri()" />

but got "Fatal Error! Could not find function: base-uri"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

胡渣熟男 2024-07-20 17:08:25

base-uri() 是标准 XPath 2.0 函数,因此在运行 XSLT 1.0 时该函数将不可用。

在 XSLT 1.0 中,文件名(什么?)可以作为转换的参数传递

请注意,并不总是能够为样式表或 XML 文档生成文件名——其中一个或两个都可能驻留在内存中而没有关联的文件。

从问题中并不清楚必须生成哪个文件名。

以下是如何在 XPath 2.0 / XSLT 2.0 中查找文件名

当前文档的文件名:

 base-uri()

当前样式表模块的文件名:

  base-uri(document(''))

base-uri() is a standard XPath 2.0 function, so when running XSLT 1.0 this function will be unavailable.

In XSLT 1.0 the filename (of what?) may be passed as a parameter for the transformation.

Do note that it isn't always possible to produce a filename for a stylesheet or for an XML document -- either or both may be residing in memory without an associated file.

It is not clear from the problem which filename must be produced.

Here is how to find filenames in XPath 2.0 / XSLT 2.0:

The filename of the current document:

 base-uri()

The filename of the current stylesheet module:

  base-uri(document(''))
极致的悲 2024-07-20 17:08:25

在 XSLT v1/XPath v1 中没有这样的 XPath 函数或 XPath 函数的 XSLT 扩展来执行此操作。

很可能没有文件,即使 XSLT 引擎没有理由使用该文件名(考虑将文件内容加载到缓冲区中,将缓冲区解析为 DOM,然后将 DOM 传递给XSLT 处理器)。

您需要将文件名传递到处理器中才能用作转换中的参数。

There is no such XPath function, or XSLT extension to XPath function to do this in XSLT v1/XPath v1.

It is quite possible for there to be no file, and even if there is no reason for the XSLT engine to have that file name (consider loading the file content into a buffer, parsing the buffer into a DOM and then passing the DOM to the XSLT processor).

You will need to pass the filename into the processor to be available as a parameter in the transform.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文