[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] RE: XSL-FO and Z-index


Subject: Re: [xsl] RE: XSL-FO and Z-index
From: Jesper Tverskov <jesper.tverskov@xxxxxxxxx>
Date: Thu, 20 Sep 2012 09:38:05 +0200

Actually I would love to do the third alternative, being the most
"correct". Except that the calculation would take me several hours to
find out. I know we have several people on this list that can do it on
the fly without having to think about it, so here is the problem.

Let us say we have a string in an xslt variable like this:

"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum."

Based on a character count from a long example for a particular font,
font-size etc (I have a feeling that a proportional font where an "i"
takes up lesser space than a "m" means we will have to work with an
average), I know that a line will take around 80 characters. If a word
is too long it will go down on next line.

It is easy to turn the string into a sequence using space as divider.
It is easy to make a new sequence that replaces the words in the
sequence with the character count of the word.

But how do I do the rest of the calculation?

I must add the items in the sequence and when I get to >= 80 I have my
first line, and must start over again, starting with the too long item
and then add the following ones, etc, and suddenly I have my next
line, and then the third. Etc.

I want the function to return the number of lines.

Cheers
Jesper Tverskov
http://www.xmlplease.com


Current Thread
Keywords