如何更改值

时间:2022-11-26 23:41:44

I can't get this to work... I simply want to change the value of a globally defined variable:

我不能让它工作......我只是想改变一个全局定义的变量的值:

                    <xsl:variable name="isBusiness"></xsl:variable>
                    <xsl:choose>
                        <xsl:when test="yes this is a business">
                               <xsl:variable name="isBusiness">true</xsl:variable>                        
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:variable name="isBusiness">false</xsl:variable>
                        </xsl:otherwise>
                    </xsl:choose>    

Obviously the code is invalid because is already defined, but how would I change the value?

显然代码是无效的,因为已经定义了,但是如何更改值呢?

1 个解决方案

#1


15  

Check this link out:

检查此链接:

http://www.dpawson.co.uk/xsl/sect2/N8090.html#d10874e187

http://www.dpawson.co.uk/xsl/sect2/N8090.html#d10874e187

Basically, your code should look like this:

基本上,您的代码应如下所示:

<xsl:variable name="x">
   <xsl:choose>
     <xsl:when test="a">z</xsl:when>
     <xsl:when test="b">zz</xsl:when>
     <xsl:otherwise>zzz</xsl:otherwise>
   </xsl:choose>
 </xsl:variable>

#1


15  

Check this link out:

检查此链接:

http://www.dpawson.co.uk/xsl/sect2/N8090.html#d10874e187

http://www.dpawson.co.uk/xsl/sect2/N8090.html#d10874e187

Basically, your code should look like this:

基本上,您的代码应如下所示:

<xsl:variable name="x">
   <xsl:choose>
     <xsl:when test="a">z</xsl:when>
     <xsl:when test="b">zz</xsl:when>
     <xsl:otherwise>zzz</xsl:otherwise>
   </xsl:choose>
 </xsl:variable>