0
votes

I am trying to pad an output in XSLT with variables being multiplied in XSLT 1.0. I cannot use the format-number because it will auto-round the numbers but I need to get the decimals in place. I can get this to work when I use column formatting within the XML, but since this has multiple column formats within the value-of-select, it does not seem to work here and obey the 7 in the code below:

            <xsl:value-of select="substring(E_BaseRate * E_NormalHours * 2, 1, 7)" disable-output-escaping="yes"/>

The output I am getting is: 1601.93 translated to 160193 but I need to get the result of 0160193. Is there a way to do this?

1
"I cannot use the format-number because it will auto-round the numbers" Please provide an example of such problem. A minimal reproducible example. - michael.hor257k
When using format-number: I get the result of: 0001602 which is the rounding result of: 0160193 - Alex Imperiale
<xsl:value-of select="format-number(E_BaseRate * E_NormalHours * 2, '0000000')" disable-output-escaping="yes"/> - Alex Imperiale
So multiply by 200 instead of 2? It's not clear what the scope of the problem is. And your example is NOT a reproducible one. - michael.hor257k

1 Answers

0
votes

I broke this out to give you an idea. You could use as is or put it all together into one select...

  <xsl:variable name="numToString" select="string(160193)"/>

  <xsl:variable name="numLen" select="string-length($numToString)"/>

  <xsl:variable name="value" select="concat(substring('0000000', 1, 7 - $numLen), $numToString)"/>