I’m trying to line up a column of numbers using XSL-FO. The numbers can be any mix of positive and negative numbers. Because they represent currency, text-align=“end” worked fine because all values had two digits after the decimal place with format-number(value, “#,##0.00”)
However, the user wants negative numbers to display with parentheses. No prob: format-number(value, “#,##0.00;(#,##0.00)”) right? The problem is now the decimals do not line up because of that trailing ).
What makes things more frustrating is: when I googled “xsl fo align decimal place” the first link was http://groups.yahoo.com/group/XSL-FO/message/5530 This appears to be what I’m looking for, but I’m not allowed to surf to yahoo.com by the rules of our firewall filter (grrrr… I dread the day straightdope.com is added to that database!) Can you check this out to see if there’s any help?
I’m going to go with
<xsl:value-of select="substring-before(format-number(value, '#,##0.00;(#,##0.00)'), '.')" />
<xsl:text>.</xsl:text>
<fo:leader leader-pattern="use-content" leader-length="3em" leader-pattern-width="3em">
<xsl:value-of select="substring-after(format-number(value, '#,##0.00;(#,##0.00)'), '.')" />
</fo:leader>
All that to display one number that, without the “display negatives in parentheses” requirement, would merely have been
<xsl:value-of select=“format-number(value, '#,##0.00” />
There must be a better way…