2016-06-28 11 views
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> 
+0

ます。http:// stackoverflow.com/help/someone-answers –

答えて

-1

それはコンテキスト(入力とスタイルシートの残りの部分の両方を)見ずに助言することは困難ですが、私は、あなたの質問に一部を書き換える可能性が信じているよう:

<xsl:variable name="quantBackOrdered"> 
    <xsl:choose> 
     <xsl:when test="quantitybackordered=''">0</xsl:when> 
     <xsl:otherwise> 
      <xsl:value-of select="quantitybackordered" /> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:variable> 

<xsl:variable name="quantAvail"> 
    <xsl:choose> 
     <xsl:when test="locationquantityavailable=''">0</xsl:when> 
     <xsl:otherwise> 
      <xsl:value-of select="locationquantityavailable" /> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:variable> 

<xsl:choose> 
    <xsl:when test="inventoryLocation_internalid='18'"> 
     <xsl:value-of select="$quantAvail - $quantBackOrdered"/> 
    </xsl:when> 
    <xsl:otherwise> 
     <xsl:value-of select="$quantAvail"/> 
    </xsl:otherwise> 
</xsl:choose> 
関連する問題