xml 如何更改 <xsl:variable> 值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6500737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 14:49:43  来源:igfitidea点击:

How to change <xsl:variable> value

xmlxslt

提问by FaNIX

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?

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

回答by code4life

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>