Reputation: 2618
I need to generate a list of links, as the maximum value, I want to do is a paginator.
Example: this variable extracts the maximum number of links.
<xsl:variable name="countPages"
select="substring-after(substring-before(
//x:div[@class='navBarBottomText']/x:span, ')'), 'till ' )" />
This case is: 30, this value is the total of links.
file XSLT:
<xsl:template match="//x:div[@class='navBarBottomText']" >
<xsl:call-template name="paginator"/>
</xsl:template>
<xsl:template name="paginator">
<xsl:param name="pos" select="number(0)"/>
<xsl:choose>
<xsl:when test="not($pos >= countPages)">
<link href="{concat('localhost/link=' + $pos)}" />
<xsl:call-template name="paginator">
<xsl:with-param name="pos" select="$pos + 1" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
The result should be something like:
<link href="localhost/link=0" />
<link href="localhost/link=1" />
<link href="localhost/link=2" />
<link href="localhost/link=3" />
<link href="localhost/link=4" />
<link href="localhost/link=5" />
<link href="localhost/link=6" />
.....
missing some parameter?. Thanks.
Upvotes: 1
Views: 58
Reputation: 243469
You could do this the way you wanted -- just use a proper variable reference:
Replace:
<xsl:when test="not($pos >= countPages)">
with:
<xsl:when test="not($pos >= $countPages)">
Here I assume that the variable $countPages
is globally defined (visible).
A non-recursive solution:
<xsl:variable name="vDoc" select="document('')"/>
<xsl:for-each select=
"($vDoc//node() | $vDoc//@* | $vDoc//namespace::*)[not(position() >= $countPages)]">
<link href="localhost/link={position() -1}" />
</xsl:for-each>
Upvotes: 1