我有一个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