xsl-list
[Top] [All Lists]

[xsl] Calculating the size of a string

2012-08-15 07:14:22
Hi List,

I have an xml input that will be processed into a FO file, via Saxon and 
Apache's FOP (1.0). The resulting string will eventually be output to a 
fo:table-cell. FOP does a decent job of hyphenating, however it is not perfect. 
If I have a string input like this:

<pnr>PN-THIS.IS.A.LONG.PN12.23.56</pnr>

The output on PDF looks like this:

PN-
THIS.IS.A.LONG.PN12.23.56

the problems is that my cell is very small. I would like to have it look like 
this:

PN-THIS.IS.A.
LONG.PN12.
23.56

I found a workaround, where if I include spaces in the string, I get better 
results:

<pnr>PN-THIS.IS.A.LONG. PN12.23. 56</pnr>

However, this requires changing the input, which I don't want to do. I can not 
use string-length because the size of the space can vary depending on the 
characters used. For example, 'WWWWW', is bigger than 'iiiii' in actual size. 
Both return a string-length of 5, but are not the same size. So, I've written a 
java extension that will return the size of the Rectangle2D width. I have an 
idea of where the 'line' break should be (140 the width of the framing 
rectangle), but I am not sure how to translate the width into a function in 
xslt to add the spaces.

Any ideas? 

Thanks for the help

Phil




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


<Prev in Thread] Current Thread [Next in Thread>