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 回答