This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Text justification with FXSL (Was: Re: String parsing, node creation)
- From: Dimitre Novatchev <dnovatchev at yahoo dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 26 Feb 2002 23:27:19 -0800 (PST)
- Subject: [xsl] Text justification with FXSL (Was: Re: String parsing, node creation)
- Reply-to: xsl-list at lists dot mulberrytech dot com
> <!-- My source XML -->
> <doc>
> <txt>
> This will be a fairly large block of text.
> Text block text block text block text block.
> It will go on for a while ... then stop.
> </txt>
> </doc>
>
> The problem I have now, is as follows: My <txt> nodes may only have
> #text nodes of a certain, very short length (say, 38 characters).
>
> So, after proper translation my xml document should look as follows:
>
> <doc>
> <txt>This will be a 256 char block of text.</txt>
> <txt> Text block text block text block text</txt>
> <txt> block. It will go on for a while ...</txt>
> <txt>then stop.</txt>
> </doc>
>
> The real hitch is the #text must be broken up by word blocks (words
> tokenized by space (' '), not purely by character length.
Use the str-split-to-lines template (file strstrSplit-to-Lines.xsl)
from the FXSL functional programming library.
It is based upon a functional tokenizer, which given a text and a set
of possible delimiters for words produces a list of words.
Thus the str-split-to-lines template can easily be modified to produce
justified text by distributing the necessary number of additional
spaces between the words that form a line.
The FXSL functional programming library can be used with the Saxon,
MSXML and Xalan XSLT processors and can be easily customised for other
XSLT processors. It is freely available at:
http://www.topxml.com/xsl/articles/fp/
or
http://www.topxml.com/downloads/default.asp?id=v20021156554
Cheers,
Dimitre Novatchev.
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list