title: How do I use an xdoxslt variable inside xsl code, in BI Publisher?
body: <p>I am trying to create a loop that increments a variable, then use that variable inside of some xsl code.  Here is the code I am using to increment the counter:</p>
  
  <pre><code>&lt;?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?&gt;
  
  &lt;?for-each-group:$g2;./STATUS?&gt;
  &lt;?sort:current-group()/STATUS;'ascending';data-type='text'?&gt;
  &lt;?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) 
     + count(xdoxslt:distinct_values(current-group()/ACTION)))?&gt;
  &lt;?end for-each-group?&gt;
  </code></pre>
  
  <p>The following code will output the number that I need:</p>
  
  <pre><code>&lt;xsl:value-of select="xdoxslt:get_variable($_XDOCTX, ‘counter’)"/&gt;
  </code></pre>
  
  <p>So I know the loop is working and the variable is has the correct number.  However, I need to use the variable in the following code:</p>
  
  <pre><code>&lt;xsl:attribute name="number-rows-spanned"  xdofo:ctx="block"&gt;
  &lt;xsl:value-of select="xdoxslt:get_variable($_XDOCTX, ‘counter’)"/&gt;
  &lt;/xsl:attribute&gt;
  </code></pre>
  
  <p>When I use it this code I get the following error:</p>
  
  <pre><code>java.lang.NumberFormatException: For input string: ""
  </code></pre>
  
  <p>I have also tried:</p>
  
  <pre><code>&lt;xsl:variable name="rowcount" select="xdoxslt:get_variable($_XDOCTX, ‘counter’)"/&gt;
  &lt;xsl:attribute name="number-rows-spanned"  xdofo:ctx="block"&gt;
  &lt;xsl:value-of select="$rowcount"/&gt;
  &lt;/xsl:attribute&gt;
  </code></pre>
  
  <p>This results in the same error.  Is there any workaround that will allow me to use a variable in this way or should I just find an alternate solution?</p>
  
  <p>This is the report I am trying to create:</p>
  
  <pre><code>Group by Column1
  
      Group by Column2
  
          Column3    | Column4    | column5   | Column6
          Group Left | Group Left | Group Left | Number
  
      End Group by Column2
  
     Totals
  
          Column3    | Column4    | column5   | Column6
          Group Left | Group Left | Group Left | sum()
  
  End Group by column1
  </code></pre>
  
  <p>The problem is that in the "Totals" table, Column6 values are being split when there is more than 1 Column2 in the grouping.</p>