未知函数 Current-Datetime()
Unknown Function Current-Datetime()
有人可以解释为什么我在这个 XSLT 中得到 current-datetime()
的未知函数吗?我在 Saxon 9.6.0.7 中使用 Oxy。我想在当前的撒克逊语中使用 XSLT 2.0,直接调用 current-datetime()
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:mns="urn:com.mydom.custom/MyNameSpace"
xpath-default-namespace="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsd">
<xsl:template match="InputFileRoot">
<mns:TransData>
<xsl:if test="string-length(Record61/ValueDate) > 0">
<mns:TransactionDate>
<xsl:call-template name="formatdate">
<xsl:with-param name="DateTimeStr" select="Record61/ValueDate"/>
<!-- <xsl:value-of select="format-dateTime(Record61/ValueDate,'[Y01]-[M01]-[D01]')" /> -->
</xsl:call-template>
</mns:TransactionDate>
</xsl:if>
<xsl:if test="string-length(SupplementaryDetails) > 0">
<mns:Addenda>
<xsl:value-of select="SupplementaryDetails" />
</mns:Addenda>
</xsl:if>
<xsl:if test="string-length(Record61/AccountServicingInstitutionsReference) > 0">
<mns:BankReferenceNumber>
<xsl:value-of select="Record61/AccountServicingInstitutionsReference" />
</mns:BankReferenceNumber>
</xsl:if>
<mns:CustomerReferenceNumber>
<xsl:value-of select="Record61/ReferenceForTheAccountOwner" />
</mns:CustomerReferenceNumber>
</mns:TransData>
</xsl:template>
<xsl:template name="formatdate">
<xsl:param name="DateTimeStr" />
<xsl:variable name="CurDate">
<xsl:value-of select="current-datetime()"/>
</xsl:variable>
<xsl:variable name="mm">
<xsl:value-of select="substring($DateTimeStr,3,2)" />
</xsl:variable>
<xsl:variable name="dd">
<xsl:value-of select="substring($DateTimeStr,5,2)" />
</xsl:variable>
<xsl:variable name="yyyy">
<xsl:value-of select="concat(substring($CurDate,1,2),substring($DateTimeStr,1,2))" />
</xsl:variable>
<xsl:value-of select="concat($yyyy,'-', $mm, '-', $dd)" />
</xsl:template>
通常错误是在需要 XSLT 2.0 的地方使用 XSLT 1.0 处理器,但这里的问题是函数调用的情况:函数名称是 current-dateTime()
, 不是 current-datetime()
.
有人可以解释为什么我在这个 XSLT 中得到 current-datetime()
的未知函数吗?我在 Saxon 9.6.0.7 中使用 Oxy。我想在当前的撒克逊语中使用 XSLT 2.0,直接调用 current-datetime()
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:mns="urn:com.mydom.custom/MyNameSpace"
xpath-default-namespace="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xsd">
<xsl:template match="InputFileRoot">
<mns:TransData>
<xsl:if test="string-length(Record61/ValueDate) > 0">
<mns:TransactionDate>
<xsl:call-template name="formatdate">
<xsl:with-param name="DateTimeStr" select="Record61/ValueDate"/>
<!-- <xsl:value-of select="format-dateTime(Record61/ValueDate,'[Y01]-[M01]-[D01]')" /> -->
</xsl:call-template>
</mns:TransactionDate>
</xsl:if>
<xsl:if test="string-length(SupplementaryDetails) > 0">
<mns:Addenda>
<xsl:value-of select="SupplementaryDetails" />
</mns:Addenda>
</xsl:if>
<xsl:if test="string-length(Record61/AccountServicingInstitutionsReference) > 0">
<mns:BankReferenceNumber>
<xsl:value-of select="Record61/AccountServicingInstitutionsReference" />
</mns:BankReferenceNumber>
</xsl:if>
<mns:CustomerReferenceNumber>
<xsl:value-of select="Record61/ReferenceForTheAccountOwner" />
</mns:CustomerReferenceNumber>
</mns:TransData>
</xsl:template>
<xsl:template name="formatdate">
<xsl:param name="DateTimeStr" />
<xsl:variable name="CurDate">
<xsl:value-of select="current-datetime()"/>
</xsl:variable>
<xsl:variable name="mm">
<xsl:value-of select="substring($DateTimeStr,3,2)" />
</xsl:variable>
<xsl:variable name="dd">
<xsl:value-of select="substring($DateTimeStr,5,2)" />
</xsl:variable>
<xsl:variable name="yyyy">
<xsl:value-of select="concat(substring($CurDate,1,2),substring($DateTimeStr,1,2))" />
</xsl:variable>
<xsl:value-of select="concat($yyyy,'-', $mm, '-', $dd)" />
</xsl:template>
通常错误是在需要 XSLT 2.0 的地方使用 XSLT 1.0 处理器,但这里的问题是函数调用的情况:函数名称是 current-dateTime()
, 不是 current-datetime()
.