我有一個XSL它看起來像:如何在XSL-循環改變變量值
<xsl:param name="relativeURL"/>
<xsl:param name="isPersonalPage" />
<xsl:template match="/">
<xsl:call-template name="main_level" >
<xsl:with-param name="urlMatched" select="siteMap/siteMapNode/siteMapNode/@url= $relativeURL" />
</xsl:call-template>
</xsl:template>
<xsl:template name="main_level" match="/">
<div>
<xsl:param name="urlMatched" />
<xsl:for-each select="siteMap/siteMapNode/siteMapNode">
<xsl:choose>
<xsl:when test="(@url = $relativeURL)">
<a class="top_link active">
<xsl:attribute name="href">
<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:value-of select="@topNavTitle"/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="($isPersonalPage = 'true') and (!($urlMatched))">
<a class="top_link active">
<xsl:attribute name="href">
<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:value-of select="@topNavTitle"/>
</a>
</xsl:when>
<xsl:otherwise>
<a class="top_link">
<xsl:attribute name="href">
<xsl:value-of select="@url"/>
</xsl:attribute>
<xsl:value-of select="@topNavTitle"/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
所以,基本上我需要遍歷節點,並看看是否有任何節點的url屬性有相匹配特定的URL。如果這樣,將變量的值設置爲別的東西。然後在被調用的模板「main_nav」中,我希望根據「urlMatched」變量的值進行操作。 但我不確定我是否可以在兩者之間改變一個變量的值。任何人都可以幫我解決這個問題嗎?
什麼將我的變量包括如果發現或沒有找到relativeUrl?因爲我需要稍後檢查這個值,並根據它進行一些編碼。 – 2013-03-25 09:39:13
@RossCooper我已經添加了一些可以幫助你的信息。 – 2013-03-25 09:55:46
嗨伊恩,我用我現在使用的實際代碼更新了問題。我仍然沒有得到所需的輸出。相反,我得到一個500錯誤。 :( – 2013-03-25 10:21:27