Search code examples
xsl-foapache-fop

Apache-FOP - howto format number retrieved with <fo:retrieve-marker/>


I am currently trying to use Apache-FOP for generating Invoices. Using <fo:retrieve-marker/> and <fo:marker/> I am able to create Subtotals for every page.

I want to format this number properly:

          <fo:block text-align="right">
            <fo:retrieve-marker retrieve-class-name="invoice-subtotal" retrieve-boundary="page" retrieve-position="last-starting-within-page"/>
          </fo:block>

Just gives me the plain Sum (e.g. 12045), want I want to have is 120,45. Is this possible with just Apache-FOP 1.1? Retrieving this number is done after the XSLT processor, so I cant use XSLT formatting functions.

Thanks for your help.


Solution

  • Ok. What I asked does not seem to be possible. What I did before was calculating the intermediate sum with XSLT:

    <fo:marker marker-class-name="invoice-subtotal"><xsl:value-of select="itemTax/grossPriceRaw + sum(preceding::itemTax/grossPriceRaw)"/></fo:marker>
    

    What I did to solve the problem is that every position in my invoice now holds the intermediate sum. So calculating and formatting is up to the programming language (in this case java).

    My marker definition now looks like this:

    <fo:marker marker-class-name="invoice-subtotal"><xsl:value-of select="intSum"/></fo:marker>
    

    So everything works fine now.

    Thanks for your help.