1

以下のような XSL を作成します。

<xsl:choose>
   <xsl:when test="range_from &lt; 0 and range_to > 5">
      <xsl:variable name="markup_03" select="((7 div $total_price_02) * 100)"/>
    </xsl:when>
    <xsl:when test="range_from &lt; 6 and range_to > 10">
      <xsl:variable name="markup_03" select="((5 div $total_price_02) * 100)"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:variable name="markup_03" select="0"/>
    </xsl:otherwise>
</xsl:choose>
<xsl:variable name="total_price_03" select="(($total_price_02 * $markup_03) div 100) + $total_price_02"/>

次のエラーが表示されます。

変数またはパラメーター 'markup_03' への参照を解決できません。変数またはパラメーターが定義されていないか、スコープ内にない可能性があります

4

1 に答える 1

2

markup_03条件の内部を宣言している<xsl:choose>ため、外部で参照しようとすると範囲外になり<xsl:choose>ます。

代わりに、あなたを宣言し、変数<xsl:variable name="markup_03">の内部をネストして、<xsl:choose>割り当てる値を決定します。

    <xsl:variable name="markup_03">
       <xsl:choose>
           <xsl:when test="range_from &lt; 0 and range_to > 5">
               <xsl:value-of select="((7 div $total_price_02) * 100)"/>
           </xsl:when>
           <xsl:when test="range_from &lt; 6 and range_to > 10">
               <xsl:value-of select="((5 div $total_price_02) * 100)"/>
           </xsl:when>
           <xsl:otherwise>
               <xsl:value-of select="0"/>
           </xsl:otherwise>
       </xsl:choose>
    </xsl:variable>
    <xsl:variable name="total_price_03" select="(($total_price_02 * $markup_03) div 100) + $total_price_02"/>
于 2012-04-22T22:56:59.443 に答える