未知函数Current-Datetime()

时间:2017-04-28 19:14:41

标签: xml xslt saxon

有人可以解释为什么我在这个XSLT中获得current-datetime()的未知功能吗?我使用Oxy和Saxon 9.6.0.7。我认为使用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>

1 个答案:

答案 0 :(得分:1)

通常错误是使用需要XSLT 2.0的XSLT 1.0处理器,但问题是函数调用的情况:函数名是 current-dateTime() current-datetime()