Subject: RE: [xsl] Decimal alignment using fo:leader From: "Angela Williams" <Angela.Williams@xxxxxxxxxxxxxxxxxx> Date: Thu, 23 Aug 2007 08:36:14 -0500 |
Thanks, Abel, for your response. Unfortunately, text-align="." is not supported by XEP - or apparently FOP. Another caveat is that each row in the column may have a different font-size or font-style that is not determined until run-time. I use the pre-process to determine the actual value and data format (precision, type, whether to display the currency or percent symbol, etc) that goes into the cell, and the final step to style or "decorate" the value. So I do need to use the fo:leader solution, I just can't get the entire set to right-align. P.S. "<<$max-precision=5>> * inherited-property-value(font-size)" is for illustration purposes - the actual value in the code is "5 * inherited-property-value(font-size)". Any other suggestions? Thanks! Angela -----Original Message----- From: Abel Braaksma [mailto:abel.online@xxxxxxxxx] Sent: Wednesday, August 22, 2007 6:43 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] Decimal alignment using fo:leader I'm not sure about xsl-fo possibilities here, but because you are using numbers, you don't need to worry about the widths, as numbers always (?) have the same width for alignment purposes. That said, you could use your xslt preprocess phase to align them properly using position, spaces or similar based on the widest result string (highest precision value). However, I realize that it is not a pretty solution. But what you should be able to do, is something along the lines of: <fo:table> <fo:table-column text-align="." column-width="auto" /> .... <fo:table-body> <fo:table-row> <fo:table-cell>52.50000</fo:table-cell> </ <fo:table-row> <fo:table-cell>10.38</fo:table-cell> </ </ </ but note that if you use Apache FOP, the text-align="$some-sting" is not supported. Cheers, -- Abel Braaksma PS: your code is not correct (it is not well-formed XML), it is not clear to me what it is supposed to do, but it can't run the way you posted it. Angela Williams wrote: > I'm sure someone smarter than I am has already solved this.... > > I'm trying to align data in an fo:table on the decimal point, with the value having the greatest precision right-aligned. All of the examples I have found show fixed width, only. > > How do you do this when you don't know the size of the font, or the width of the column? > > I've tried to calculate the leader-length, but I'm not having any luck getting it to right align. How could I change this to make it work? > > This is what I have: > > <fo:table-cell column-number="4" border=".1mm solid black" > padding-start="5%" padding-before="2pt" padding-end="5%"> > <fo:block text-align="right" font-size="8pt"> 52<fo:leader > leader-pattern="use-content" leader-length="<<$max-precision=5>>* inherited-property-value(font-size)" > leader-pattern-width="<<$max-precision=5>> * inherited-property-value(font-size)">.50000</fo:leader> > </fo:block> > </fo:table-cell> > > <fo:table-cell column-number="4" border=".1mm solid black" > padding-start="5%" padding-before="2pt" padding-end="5%"> > <fo:block text-align="right" font-size="8pt"> 10<fo:leader > leader-pattern="use-content" > leader-length="<<$max-precision=5>> * inherited-property-value(font-size)" > leader-pattern-width="<<$max-precision=5>> * inherited-property-value(font-size)">.38</fo:leader> > </fo:block> > </fo:table-cell> > > This gives me (assume a border-bottom in the fo:block within the last row): > +-------------------+ > | 52.50000 | > | 10.38 | > | ---------------- | > +-------------------+ > > But I need: > +-------------------+ > | 52.50000 | > | 10.38 | > | ---------------- | > +-------------------+ > > Thanks in advance! > Angela Williams > Software Developer > The 401k Company, A Charles Schwab Company > 98 San Jacinto Blvd. ~ Suite 1100 ~ Austin, TX 78701 > Office: 512.344.1547 ~ Fax: 512.397.6656 > Angela.Williams@xxxxxxxxxxxxxxxxxx
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Decimal alignment using f, Abel Braaksma | Thread | RE: [xsl] Decimal alignment using f, Angela Williams |
Re: [xsl] Decimal alignment using f, Abel Braaksma | Date | RE: [xsl] Decimal alignment using f, Angela Williams |
Month |