Question

There is a question with a similar title, but an entirely different question body: How to increment a XSL integer variable

I get a parameter $level passed to a template and want to apply templates on $level + 1, while $level is guaranteed to always be a strictly positive integer. I have this computation right now, but it seems awful. Ther's got to be a better way:

<xsl:with-param name="level" select="ceiling(number(concat($level,'.9')))" />

This works, but I was wondering if you could directly use xpath:sum direcly, but I struggle because the literal 1 is not a node on its own.

So, is there a better expression for the ceiling(number(concat($level,'.9'))) part?

Was it helpful?

Solution

<xsl:with-param name="level" select="ceiling(number(concat($level,'.9')))" />

Just use:

<xsl:with-param name="level" select="$level+1"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top