Re: [xsl] Simple Word Wrap?

Subject: Re: [xsl] Simple Word Wrap?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 28 Sep 2007 20:56:31 +0200
At 2007-09-28 13:43 -0500, Luke Jones wrote:
I have a somewhat unique problem.  I'm converting legal xml documents
into pdfs and I've run into a big of a snag.

Actually, this shows up with long URI strings quite often. I have it in many of my production XSL-FO stylesheets.


In one particular document, I'm dealing with drugs.  So I have "words"
that look like
"N-(3-methyl-1-(2-phenylethyl)-4-piperidly)-N-phenylpropanamide".  Since
the block area I'm working in needs to be justified text, you might see
where "words" of that length cause many aesthetic issues within the pdf.
I've tried to go in manually and enter spaces where I felt a word wrap
should take place.  However, due to the nature of how justification is
handled is xsl, this doesn't seem to be a viable option as I'm still
left with rather large gaps between words.

Does anyone know of a way to keep my justification as well as manage
words so as to keep the flow of text consistent throughout the document?

By injecting a zero-width space (&#x200b;) where you want to allow a line break to happen. If no line break is needed, there is no visual disturbance. If a line break is needed, the line breaks at the space.


For example, you could have the following in XSLT 2.0:

replace(replace(.,'(','&#x200b;('),')',')&#x200b;')

... which injects a zero-width space before each left parenthesis and after each right-parenthesis.

In URI strings I inject them after each slash.

The presentation treats the character as a space, but the character doesn't take any room on the line, thus presenting a string as if it were unbroken.

I hope this helps.

. . . . . . . . . . . . Ken

--
Upcoming public training: UBL and code lists Oct 1/5; Madrid Spain
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Jul'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread