0
以下是我的代碼。基本上,問題是我需要能夠檢查一個節點,如果它是空的,將它設置爲0,但如果它有一個值,則將其設置爲該值。之後我需要對它進行數學運算(減去數值)。下面是我嘗試過的,但是我收到一個錯誤:「變量參數'quantAvail'要麼沒有定義,要麼超出了範圍。」我不知道如何解決這個問題?檢查節點是否爲空,如果爲空值設爲
<xsl:choose>
<xsl:when test="quantitybackordered=''">
<xsl:variable name="quantBackOrdered" select="0"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="quantBackOrdered" select="quantitybackordered"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="locationquantityavailable=''">
<xsl:variable name="quantAvail" select="0"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="quantAvail" select="locationquantityavailable"/>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="inventoryLocation_internalid='18'">
<xsl:variable name="quantTotal" select="$quantAvail - $quantBackOrdered"/> <!-- Error on this line -->
<xsl:value-of select="$quantTotal"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="test" select="locationquantityavailable"/>
<xsl:choose>
<xsl:when test="$test=''">
<xsl:text>0</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="locationquantityavailable"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
的http:// stackoverflow.com/help/someone-answers –