<?xml version="1.0"?>
<!-- ============================================================ -->
<!--                                                              -->
<!-- 	This file makes a part of RenderX XSL Test Suite          -->
<!--                                                              -->
<!--    Author: Alexander Peshkov                                 -->
<!--                                                              -->
<!--    (c) RenderX, 2004                                         -->
<!--                                                              -->
<!-- ============================================================ -->
<document>
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
           xmlns:dc="http://purl.org/dc/elements/1.1/"
           xmlns:dcterms="http://purl.org/dc/terms/"
           xmlns:db="http://www.oasis-open.org/docbook/xml/4.2/">
    <rdf:Description rdf:about="http://xep.xattic.com/testsuite/usecases/marginalia.xml">
        <dc:creator>Alexander Peshkov</dc:creator>
        <dc:title>Decimal point alignment using <db:sgmltag class='starttag'>fo:list-block</db:sgmltag> or <db:sgmltag class='starttag'>fo:leader</db:sgmltag></dc:title>
        <dc:description>
          <db:para>
            Emulates an effect of <db:sgmltag class='attribute'>text-alignment="."</db:sgmltag> using
            <db:sgmltag class='starttag'>fo:list-block</db:sgmltag> or <db:sgmltag class='starttag'>fo:leader</db:sgmltag>
            elements.
          </db:para>
        </dc:description>
        <dc:date>2004-10-25</dc:date>
        <dcterms:requires rdf:resource="http://xep.xattic.com/testsuite/usecases/generic.xsl"/>
        <dcterms:requires rdf:resource="http://xep.xattic.com/testsuite/usecases/decalign.xsl"/>
    </rdf:Description>
  </rdf:RDF> 
  <section>
  <title>Decimal point alignment using <code>fo:list-block</code> or <code>fo:leader</code></title>
  <para>
    To align text on a decimal point without using <code>text-align="."</code>,
    you have to split the number into two parts (integer and fraction) and
    format them separately (splitting can be done in XSLT). The most
    concise method is to wrap the fractional part into a leader with fixed
    length; then you can align the whole to the right. More or less like
    this:
	<codeblock>
$123,456&lt;fo:leader leader-pattern="use-content"
                   leader-length="18pt"
                   leader-pattern-width="18pt"&gt;.78&lt;/fo:leader&gt;	
	</codeblock>	
  </para>
  <para>
    Code above guarantees the fixed distance of 18pt
    from the decimal point to the right edge of the inline object,
    regardless of the actual length of the fractional part. Aligning
    these constructs to the right produces the desired effect.
  </para>
  <para>
    The method discussed above is not the only one.
    You can also put the integer and the fraction to adjacent
    cells in a table, or to label/body of a list object. These
    methods are more verbose albeit conceptually simpler.
    Code below demonstrates decimal point alignment created with 
    <code>fo:list-block</code> element:
	<codeblock>
&lt;fo:list-block start-indent="0in"
               provisional-label-separation="0pt"
               provisional-distance-between-starts="60pt"&gt;
	&lt;fo:list-item&gt;
		&lt;fo:list-item-label end-indent="label-end()"&gt;
			&lt;fo:block text-align="right"&gt;$123,456&lt;/fo:block&gt;
		&lt;/fo:list-item-label&gt;
		&lt;fo:list-item-body start-indent="body-start()"&gt;
			&lt;fo:block text-align="left"&gt;.78&lt;/fo:block&gt;
		&lt;/fo:list-item-body&gt;
	&lt;/fo:list-item&gt;
&lt;/fo:list-block&gt;
	</codeblock>
  </para>
  <para>
    With the code cited above distance between left edge of the parent area and decimal point
    is fixed to 60pt.
  </para>
  <para>
    Below is the table with two columns, every column is 120pt wide and contain some 
	numeric data aligned by decimal point.
	In the first column data is aligned using 'fo:list-block' method cited above,
	in the second column using 'fo:leader' method.
  </para>
  
  <table width="240pt">
  <colspec display-align="center" colwidth="120pt"/>
  <colspec display-align="center" colwidth="120pt"/>
  <table-body>
    <row>
      <entry border="thin solid silver">
        <simpara decalign="list" fixed-width="80pt">$123,465.78</simpara>
      </entry>
      <entry border="thin solid silver">
        <simpara decalign="leader" fixed-width="30pt">$123,465.78</simpara>
      </entry>
    </row>
    <row>
      <entry border="thin solid silver">
        <simpara decalign="list" fixed-width="80pt">$545.1</simpara>
      </entry>
      <entry border="thin solid silver">
        <simpara decalign="leader" fixed-width="30pt">$545.1</simpara>
      </entry>
    </row>
    <row>
      <entry border="thin solid silver">
        <simpara decalign="list" fixed-width="80pt">$1,000.00</simpara>
      </entry>
      <entry border="thin solid silver">
        <simpara decalign="leader" fixed-width="30pt">$1,000.00</simpara>
      </entry>
    </row>
    <row>
      <entry border="thin solid silver">
        <simpara decalign="list" fixed-width="80pt">$99.99</simpara>
      </entry>
      <entry border="thin solid silver">
        <simpara decalign="leader" fixed-width="30pt">$99.99</simpara>
      </entry>
    </row>
  </table-body>
  </table>
  </section>


</document>