How do I use an xdoxslt variable inside xsl code, in BI Publisher?
I found a workaround, I would prefer a more elegant solution but at least it works. What I did was made the last column basically a "ghost" column (no field and no borders). Then I inserted a table with two columns into column5. The tags where placed before and after the table. In the table I put the value for column5, and the sum I needed in column6. It's not perfect, there are some small formatting issues. I would prefer a better solution, if anyone has any suggestions.
Angel
Updated on June 04, 2022Comments
-
Angel almost 2 years
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:
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?> <?for-each-group:$g2;./STATUS?> <?sort:current-group()/STATUS;'ascending';data-type='text'?> <?xdoxslt:set_variable($_XDOCTX, ‘counter’, xdoxslt:get_variable($_XDOCTX, ‘counter’) + count(xdoxslt:distinct_values(current-group()/ACTION)))?> <?end for-each-group?>
The following code will output the number that I need:
<xsl:value-of select="xdoxslt:get_variable($_XDOCTX, ‘counter’)"/>
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:
<xsl:attribute name="number-rows-spanned" xdofo:ctx="block"> <xsl:value-of select="xdoxslt:get_variable($_XDOCTX, ‘counter’)"/> </xsl:attribute>
When I use it this code I get the following error:
java.lang.NumberFormatException: For input string: ""
I have also tried:
<xsl:variable name="rowcount" select="xdoxslt:get_variable($_XDOCTX, ‘counter’)"/> <xsl:attribute name="number-rows-spanned" xdofo:ctx="block"> <xsl:value-of select="$rowcount"/> </xsl:attribute>
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?
This is the report I am trying to create:
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
The problem is that in the "Totals" table, Column6 values are being split when there is more than 1 Column2 in the grouping.