2

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?

Community
  • 1
  • 1
bitmask
  • 32,434
  • 14
  • 99
  • 159
  • 1
    I am not sure I understand the problem. Your text says "I ... want to apply templates on $level + 1" so I wonder why you do not do that simply with i.e. ``? – Martin Honnen Apr 08 '12 at 17:38
  • @MartinHonnen: Because I'm stupid! Didn't know XSL would understand that and didn't think of trying it. It does what I want. Post an answer, so I can accept it, please. – bitmask Apr 08 '12 at 17:46

1 Answers1

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

Just use:

<xsl:with-param name="level" select="$level+1"/>
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431