# XSL-FO and decimal alignment

**URL:** <https://boards.straightdope.com/t/xsl-fo-and-decimal-alignment/333567>\
**Category:** Factual Questions\
**Created:** [December 1, 2005, 4:11pm UTC](https://boards.straightdope.com/t/xsl-fo-and-decimal-alignment/333567 "2005-12-01T16:11:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nature\_s\_Call](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/nature_s_call/32/19006_2.png) [@Nature\_s\_Call](https://boards.straightdope.com/u/Nature_s_Call)\
**Post date:** [December 1, 2005, 4:11pm UTC](https://boards.straightdope.com/t/xsl-fo-and-decimal-alignment/333567/1 "2005-12-01T16:11:02Z")

</div>

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](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](http://yahoo.com) by the rules of our firewall filter (grrrr… I dread the day [straightdope.com](http://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

```auto

<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…

---

<div class="post-metadata">

**Author:** ![Nature\_s\_Call](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/nature_s_call/32/19006_2.png) [@Nature\_s\_Call](https://boards.straightdope.com/u/Nature_s_Call)\
**Post date:** [December 1, 2005, 4:20pm UTC](https://boards.straightdope.com/t/xsl-fo-and-decimal-alignment/333567/2 "2005-12-01T16:20:15Z")

</div>

Found it (sorta)

[http://www.dpawson.co.uk/docbook/styling/fo.html#d2635e931](http://www.dpawson.co.uk/docbook/styling/fo.html#d2635e931)  
says that the answer is **text-align="’.’"** , i.e. the single quoted string “dot” within the double quotes.

However, we’re using XEP to render FO and  
[http://www.renderx.com/reference.html#ftn.d0e2370](http://www.renderx.com/reference.html#ftn.d0e2370)  
says it’s not implemented.  
So, allow me to modify the original question thusly,

1. is there a better way other than **text-align="’.’"**? The values _are_ in a table and I considered having a column for left of decimal and a column for right, but rejected in as costing too much in maintenance later if formatting ever changes.

2. This may be more IMHO, but… What alternatives to XEP would you suggest? Not only would something more fully implemented be welcome, but something that renders way faster - esp. with huge (50MB - 100 MB or larger) FO files?
