Q:

Make calculations with xsl:number

If I use xsl:number, I will get a number as a text of the output document. But how can I add another number to it?
I'm using it to keep track of elements, so to get their index so to speak.
If I say
<xsl:number/> + $somenumber
I would get something like 5+6 but not 11.

A:

Try storing xsl:number in an xsl:variable and performing the calculation in an xsl:value-of (or an AVT if it's going to be an attribute value)...
XML Input
<doc>
    <foo/>
    <foo/>
    <foo/>
    <foo/>
    <foo/>
</doc>

XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output indent="yes"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="foo">
        <xsl:variable name="nbr">
            <xsl:number/>
        </xsl:variable>
        <foo attr="{$nbr + 10}"><xsl:value-of select="$nbr + 10"/></foo>
    </xsl:template>

</xsl:stylesheet>

XML Output
<doc>
   <foo attr="11">11</foo>
   <foo attr="12">12</foo>
   <foo attr="13">13</foo>
   <foo attr="14">14</foo>
   <foo attr="15">15</foo>
</doc>

A:

Sometimes the technique suggested by @DanielHaley is best. Sometimes you can use position() instead of xsl:number. Sometimes it's simplest to use an expression like count(preceding-sibling::x) in place of xsl:number.

