0

Aligning pure text to the right side of a document is easy in XSL-FO. However, aligning an entire table to the right side of the document is proving to be quite difficult.

What I wish to do is something like this:

fo:table align=left

{Table content}

/fo:table

And I am aware that there is an <fo:float> object, but it does not seem to work in the way I want it to, or if it does, the explanation for how it works is poorly-worded in every instance I've been able to find.

In short: How can I make a table float to the left in XSL-FO?

EDIT: I've figured out why Float doesn't work. Apparently it's not supported in our version of Apache FOP. Any known alternatives?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Zibbobz
  • 725
  • 1
  • 15
  • 41

2 Answers2

3

The term "float" has specific meaning in XSL-FO. If you mean to take the table out of the vertical flow, put it at the start-side of the page, and have the rest of the flow continue on the end-side of the table, then <float float="start"><table>...</table></float> is the way to do it in XSL-FO.

Your question's title and text talks about floating to the "right", so then I'm assuming you mean floating to the end-side of the page. That would be, of course <float float="end">.

If it is not your intention to take the table out of the flow, rather you wish to simply flow the table and align the table on the end-side of the page, that is accomplished in XSL-FO by using <table-and-caption text-align="end"> and then not using a caption. But not all commercial XSL-FO engines support the specification in this regard.

I cannot advise you on FOP as it isn't a tool that I have used for any of my customers.

G. Ken Holman
  • 4,333
  • 16
  • 14
  • I do apologize for the lax nature of my explanation. I admit that, when it comes to technical terminology (such as the exact meaning of the "float" object), I tend to be a little less eloquent than I ought to be. Unfortunately, I've tried using your solution as given (are you certain it's and not , by the way?) but it seems not to work for my version of FOP (In either case). However, I would not discourage others from using it, if they're using a different driver. – Zibbobz Jul 29 '13 at 15:56
  • 3
    In my stylesheets I use `xmlns="http://www.w3.org/1999/XSL/Format"` so that I can write `` without the prefix. There is nothing special about the "fo:" prefix ... it could be `` if `xmlns:hello="http://www.w3.org/1999/XSL/Format"`. – G. Ken Holman Jul 29 '13 at 16:11
0

After some experimentation, I've come up with a solution. It's...inelegant, to say the least, but it works. This will produce a table that is right-adjusted by 7cm with a 3cm column and a 5cm column, though it will prevent the user from writing any content to the left of the table, unless very carefully formatted into the blank 7cm columns.

fo:table width="15cm"
fo:table-column column-width="7cm"/
fo:table-column column-width="3cm"/
fo:table-column column-width="5cm"/
fo:table-row
fo:table-cell border="none"
[Intentionally left blank]
/fo:table-cell
fo:table-cell border="solid"
[Content of 3cm column]
/fo:table-cell
fo:table-cell border="solid"
[Content of 5cm column]
/fo:table-cell
/fo:table-row
/fo:table

Note that this has some flaws (not being able to write to the left of the table without explicitly formatting it for each row, being very inelegant), but it works as a solution in Apache FOP.

Zibbobz
  • 725
  • 1
  • 15
  • 41
  • not elegant and not a float, that is formatting a three column table with two columns of content. "Float" means float me around and allow content to flow around me. So its not really an answer to your question unless you worded it incorrectly. – Kevin Brown Jul 30 '13 at 03:39
  • I guess it's more a solution to my problem than an actual answer to the quesstion. An ideal answer would work for any case, and allow for text wrap-around (which I don't actually want in this case, but I was trying to ask a question that could lead to an answer that would apply for more than just my situation). – Zibbobz Jul 30 '13 at 14:27