在 XSLT 1.0 中使用 EXSLT 日期和时间模块会产生未知错误

发布于 2024-09-02 05:00:34 字数 428 浏览 1 评论 0原文

我在 XSLT 1.0 文件中添加了 EXSLT 日期和时间模块,声明如下:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ... xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date">

这不会影响生成的页面,但是当我尝试使用以下命令调用实际日期时:

<xsl:value-of select="date:date-time()"/>

我收到一条“加载样式表时出错:未知错误加载我的页面时发生 ()”消息。 有人对我可能缺少的内容有什么建议吗?提前致谢!

I added the EXSLT dates-and-times module in my XSLT 1.0 file by declaring:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ... xmlns:date="http://exslt.org/dates-and-times" extension-element-prefixes="date">

This doesn't affect my resulting page, but when I try to call the actual date with:

<xsl:value-of select="date:date-time()"/>

I receive an "Error loading stylesheet: An unknown error has occurred ()" message when loading my page.
Does anyone have a suggestion as to what I might be missing? Thanks in advance!

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

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

发布评论

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

评论(1

樱花细雨 2024-09-09 05:00:34

但是当我尝试调用实际的
日期:

<代码>

我收到了
“加载样式表时出错:An
发生未知错误 ()”消息
加载我的页面时

这意味着您正在使用的特定 XSLT 处理器未实现 EXSLT(或仅实现 EXSLT 的日期时间模块)。

这是一个小转换

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:date="http://exslt.org/dates-and-times"
 >
 <xsl:output method="text"/>

 <xsl:template match="/">
   <xsl:value-of select="date:date-time()"/>
 </xsl:template>
</xsl:stylesheet>

当使用 Saxon 6.5.4 XSLT 1.0 处理器应用于任何 XML 文档(未使用)时,会生成正确的结果

2010-05-22T12:49:44-07:00

解决方案:

要么使用实现 EXSLT 的 XSLT 1.0 处理器,要么将当前日期时间作为参数传递给转换。

如果使用 XSLT 2.x,只需使用 XPath 2.0 函数 current-dateTime()

but when I try to call the actual
date with:

<xsl:value-of
select="date:date-time()"/>

I receive
an "Error loading stylesheet: An
unknown error has occurred ()" message
when loading my page

This means that the particular XSLT processor you're using doesn't implement EXSLT (or just the date-time module of EXSLT).

Here is a small transformation:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:date="http://exslt.org/dates-and-times"
 >
 <xsl:output method="text"/>

 <xsl:template match="/">
   <xsl:value-of select="date:date-time()"/>
 </xsl:template>
</xsl:stylesheet>

when applied to any XML document (not used), with the Saxon 6.5.4 XSLT 1.0 processor, the correct result is produced:

2010-05-22T12:49:44-07:00

Solution:

Either use an XSLT 1.0 processor that implements EXSLT, or pass the current date-time as a parameter to the transformation.

If using XSLT 2.x, just use the XPath 2.0 function current-dateTime().

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