0
我想在xslt2中添加兩個變量。該想法是下個月(如果是上個月,可能會增加一年)。net.sf.saxon.trans.XPathException:算術運算符沒有爲類型參數(xs:string,xs:string)定義
我使用的代碼如下:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes" exclude-result-prefixes="xsl xs fn xdt">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:param name="filter_date"/>
<xsl:variable name="Current_Date">
<xsl:choose>
<xsl:when test="$filter_date">
<xsl:value-of select="$filter_date"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-date(current-date(), '[Y0001][M01][D01]')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="Current_Month" select="substring($Current_Date,5,2)"/>
<xsl:variable name="Current_Year" select="substring($Current_Date,1,4)"/>
<xsl:variable name="One">1</xsl:variable>
<xsl:variable name="Month">
<xsl:choose>
<xsl:when test="$Current_Month = '12'">
<xsl:text>01</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Current_Month + '0' + $One"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="Year">
<xsl:choose>
<xsl:when test="$Current_Month = '12'">
<xsl:value-of select="sum($Current_Year + $One)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$Current_Year"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<out>
<xsl:value-of select="concat($Year, $Month, '20')" />
</out>
</xsl:template>
但我得到一個錯誤
net.sf.saxon.trans.XPathException:算術運算符無定義類型參數(xs:string,xs:string)。
感謝您的迴應和幫助。該功能有助於:)祝你有美好的一天。 – Vicky