函数当前日期xslt不起作用



我试图在xslt中使用当前日期函数,但它不起作用。我会错过什么吗?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:func="http://exslt.org/functions" 
        xmlns:date="http://exslt.org/dates-and-times"
        extension-element-prefixes="date" date:doc="http://www.exslt.org/date">
        <xsl:output method="xml" indent="yes"/>
          <xsl:template match="/">
              <value><xsl:value-of select="current-date()"/></value>
          </xsl:template>
</xsl:stylesheet>

我得到了一个错误:错误al-comprobar el tipo de la expressionón'funcall(当前日期,[])'。',它的意思是"检查表达式‘funcall(当前日期)’时出错"

为什么不起作用?

您可能尝试过以下(来自XSLT1)吗

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:func="http://exslt.org/functions" 
        xmlns:date="http://exslt.org/dates-and-times"
        extension-element-prefixes="date" date:doc="http://www.exslt.org/date">
        <xsl:output method="xml" indent="yes"/>
          <xsl:template match="/">
              <value><xsl:value-of select="date:date()"/></value>
          </xsl:template>
</xsl:stylesheet>

它只返回日期(带时区)

current-date是一个XSLT2.0函数。

但由于您使用的是EXSLT,呼叫date:date()将返回当前日期:

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

最新更新