I have this xslt :
<xsl:param name="total_articles" select="3" />
<xsl:param name="articles_per_page" select="3" />
<xsl:apply-templates select="dagboek/entry[position > $offset][position < $articles_per_page+$offset]" >
<xsl:with-param name="total_pages" tunnel="yes">
<xsl:choose>
<xsl:when test="$value="2005-09" and $page="1">8</xsl:when>
<xsl:otherwise>floor(number($total_articles)-1) div $articles_per_page +1</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:apply-templates>
But now I get this error.
How can I calculate the outcome of the calculation and put it into the param total_pages.
Roelof
Edit 1: WHat I try to achieve is that if it’s not 2005-09 and page is not 1 then the totalpages is calculated out of total_articles and articles_per_page. The outcome has to be put into the param pages.
This isn’t even well-formed XML document. The problem is with the nested quotes.
Probably you meant:
Another possible problem: Tunnel parameters are only available in XSLT 2.0. You seem to be using XSLT 1.0
Update:
The OP in a comment has modified/clarified his initial question:
This can simply be expressed as:
Explanation:
We are using the fact that in XPath 1.0 by definition
number($someBoolean)is1if$someBooleanistrue()and is0if$someBooleanisfalse().Therefore the pseudocode:
can be expressed with a single XPath expression:
whenever a boolean is an argument to an arithmetic operator, it is automatically converted to a number.
So, here’s what happens at run-time:
Suppose
$vCondistrue(), thereforenot($vCond)isfalse().Because
$vCondandnot($vCond)are arguments to the*operator, they are converted to numbers, respectively1and0:…
…
Note:
The above equivalence rule can be further generalized to N mutually exclusive conditions
$vCond1,$vCond2, …,$vCondN, and corresponding N values:$val1,$val2, …,$valN:is equal to
$valK(kin{1,..., N}) exactly when$vCondKistrue()