我創建了一個全局變量,並在兩個模板其被用於我能夠訪問我第一個模板,沒能獲得在第二模板中的值。下面是我的工作方式如何在多個模板標籤訪問全局變量的值
<xsl:variable name="currentValue"></xsl:variable> //global variable declaration
<xsl:template match="/">
<xsl:variable name="unique-accounts" select="/*/*/*/accountId/text()generate-id()=generate-id(key('account-by-id', .)[1])]"/>
<xsl:for-each select="$unique-accounts">
<xsl:variable name="currentValue" select="current()"/>
<xsl:value-of select="$currentValue"/> //here value is printing
<xsl:apply-templates select="//secondTemplate"/>
</xsl:for-each>
</xsl:template> //close od first template
<xsl:template match="secondTemplate">
<xsl:value-of select="$currentValue"/> //here value is not printing
</xsl:template>
有來自從第一template..so,它可以用來或第二模板消耗我的情況下,商店template..here內的任何工作了存儲值到全局變量 – Brittas 2015-02-09 10:59:12
你可以把它作爲一個參數* *當你打電話/申請其他模板。 – 2015-02-09 11:10:20
@Brittas是這個問題的回答?如果是,請通過接受答案關閉它。 – 2015-02-19 10:16:32