EXSLT语法问题

发布于 2024-08-07 04:46:31 字数 624 浏览 2 评论 0原文

毫无疑问,这将是显而易见的事情,但以下代码在标记行上有 2 个错误:

<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:import href="date/date.xsl" />

  <xsl:template match="//day">
    <td>
      <date:day-in-month(<xsl:value-of select='@start_date' />)/> <!--problem here-->
    </td>
  </xsl:template>   
</xsl:stylesheet>

错误是:

  • 标记缺少右括号 '>'
  • 缺少结束标记“日期:月中的某天”

据我所知,这两种情况都不是。有什么想法,还是我只是盲目的?

No doubt this will be something obvious, but the following code has 2 errors on the marked line:

<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:import href="date/date.xsl" />

  <xsl:template match="//day">
    <td>
      <date:day-in-month(<xsl:value-of select='@start_date' />)/> <!--problem here-->
    </td>
  </xsl:template>   
</xsl:stylesheet>

The errors are:

  • Tag missing closing bracket '>'
  • Missing end tag "date:day-in-month"

So far as I can see neither of those is the case. Any thoughts, or am I just blind?

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

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

发布评论

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

评论(1

草莓酥 2024-08-14 04:46:31

对于初学者来说,XSLT 必须始终是有效的 XML。你的显然不是,因为你将一个标签嵌套在另一个标签中。这是你做错事的第一个线索。

其次,date:day-in-month 是一个 XPath 函数,而不是一个元素,因此必须在 XPath 表达式中使用。例如,后者可以是 xsl:value-of/@select 属性的值:

<xsl:value-of select='date:day-in-month(@start_date)' />

For starters, XSLT must always be valid XML. Yours clearly isn't, since you nest one tag inside another. This is your first clue that you do something wrong.

Second, date:day-in-month is an XPath function, not an element, and therefore must be used in an XPath expression. The latter can, for example, be a value of xsl:value-of/@select attribute:

<xsl:value-of select='date:day-in-month(@start_date)' />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文