开发者

How do we change the value of a variable based on another variable?

I have two variables named editable and display.

If the value of editable is true, I want to set the value of display to 'block'.

If the value of editable is false, I want to set the value of display to 'none'.

This is what I have currently:

   <xsl:param name="editable" select="true()"/>
   <xsl:choose&g开发者_Go百科t;
      <xsl:when test="$editable">
         <xsl:variable name="display" select="'block'"/>
      </xsl:when>
      <xsl:otherwise>
         <xsl:variable name="display" select="'none'"/>
      </xsl:otherwise>
   </xsl:choose>

The code above doesn't set the value of display to none.

How do we change the value of a variable based on another variable?


I did not test this, but for me it looks like a problem of scope which might be solved this way:

   <xsl:param name="editable" select="true()"/>
   <xsl:variable name="display">
      <xsl:choose>
         <xsl:when test="$editable">
            <xsl:value-of select="'block'"/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="'none'"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:variable>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜