Subject: RE: [xsl] Center string From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Thu, 11 Jun 2009 12:58:51 +0100 |
I think you need to move from (0) a set of examples, to (1) a requirement statement, to (2) an algorithm, to (3) an implementation in XSLT code. Perhaps (1) is something like: generate the output in as few lines as possible given the maximum line length, and then divide the words between lines so as to minimize the maximum variation between actual line length and average line length. Perhaps (2) is something like: (a) compute the minimum number of lines by first trying to pack the words as densely as possible. (b) compute the average line length by dividing the total length by the minimum number of lines (c) flow the words into lines breaking each line at the closest possible point to the average line length. If that's OK, then step (3) is relatively straightforward so long as you are comfortable with recursion, though like most such things it's likely to be much easier in XSLT 2.0 than in 1.0. Regards, Michael Kay http://www.saxonica.com/ http://twitter.com/michaelhkay > -----Original Message----- > From: djidjoenator@xxxxxxxxx [mailto:djidjoenator@xxxxxxxxx] > On Behalf Of Fridiric Schwebel > Sent: 11 June 2009 12:42 > To: xsl-list > Subject: [xsl] Center string > > Hi folks, > > Just curious if it has already been done : I need to center a > string with a max line length. The words must be uncut and > balanced between lines. > > Example : > ---------------- > (mathimatiques niveau lycie: sirie > '1 > ----------------- is incorrect > > (mathimatiques > niveau lycie: sirie > '1 > ----------------- is incorrect > > (mathimatiques niveau > lycie: sirie '1 > ----------------- is correct > > Centering the lines is not a problem. The most difficult part > is to balance words with line-length. Did somebody already do > this with XSL ? > Thanks for any help, > Frederic
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Center string, Michael Ludwig | Thread | Re: [xsl] Center string, Frédéric Schwebel |
Re: [xsl] Center string, Michael Ludwig | Date | Re: [xsl] Center string, Frédéric Schwebel |
Month |