Search code examples
line-breaksxsl-foapache-fop

XSL-FO / Apache FOP break line at comma,semicolon etc


I didn't succeed in finding an answer to this question concerning linebreaks:

how can I tell the XSL-FO Processor (I am using Apache FOP) to break long lines not only at whitespaces but also on comma, semicolon, minus, maybe backslashes etc.?

For example, if I have a text like "Hello I am using Apache FOP" and the place is not enough it will break totally fine at one of the whitespaces; but a text that is like "one,two,three,four,five,six" won't break.


Solution

  • You insert the zero-width space character. How you insert this into your output depends on what XSLT version you are using. By regex (XSLT 2) or recursive template (XSLT 1) would likely be the ways but you have not provided details on how the content is derived and processed.

    In your example, you would have ...

    one,​two,​three,​four,​five,​six

    This would insert breaking spaces after the commas in your list.