1
這裏是我的XSLT:XSLT中的變量作用域?
<xsl:choose>
<xsl:when test="string-length(/*/location/name)">
<xsl:variable name="pagurl">/location/<xsl:value-of select="/*/location/@id" />comments</xsl:variable>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="pagurl">/state/<xsl:value-of select="/*/state/@code" />/comments</xsl:variable>
</xsl:otherwise>
</xsl:choose>
<div class="pagination_outer" id="pager">
<xsl:call-template name="pagination">
<xsl:with-param name="url"><xsl:value-of select="$pagurl"/></xsl:with-param>
</xsl:call-template>
</div>
我做了以下內容:
- 分配一個變量
$pagurl
基於字符串長度的值。 - 試圖使用呼叫
<xsl:with-param name="url"><xsl:value-of select="$pagurl"/></xsl:with-param>
裏面的變量。當我包括此調用頁面似乎永遠不過完成加載,當我不使用它的頁面加載就好了。 我想我在使用這個時出現錯誤。
我不認爲有必要看到pagination template
,因爲它工作正常,如果我硬編碼一個值。
對此提出建議?
貌似你試圖[執行動態的XPath(http://stackoverflow.com/questions/4630023/dynamic-xpath-in-xslt)? – har07
@ har07,不,它沒有那麼複雜 - 只是[範圍界定問題](http://stackoverflow.com/a/35763135/290085)。 – kjhughes