2012-11-26 37 views
1

在這裏,我試圖運行一個循環,搜索整個XML並根據各種條件的不同變量得到不同的值。這樣它可以在以後作參考使用。如何重新分配值的變量在XSLT

示例代碼:

<xsl:for-each select='root'> 
<xsl:choose> 
    <xsl:when test='first'> 
    <xsl:variable name='first' select='root/first' /> 
    </xsl:when> 
    <xsl:when test='second'> 
    <xsl:variable name='namew' select='root/second' /> 
    </xsl:when> 
    <xsl:otherwise> 
    <xsl:variable name='other'>unknown</xsl:variable> 
    </xsl:otherwise> 
    </xsl:choose> 

我知道它不會在這裏工作,我也知道的原因(可變範圍和可變的恆定行爲),其實我想知道的替代解決這個問題。

回答

0

XSLT是一種功能性的語言。

在許多事情,這意味着一個變量,一旦定義,的值不能被改變。

如果指定要解決特定的問題,我們許多人將能夠給你哪些變量的值不被改變的解決方案。