[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: how to make data fit in a table cell in xsl-fo?

Subject: Re: how to make data fit in a table cell in xsl-fo?
From: yan bai <bytj@xxxxxxxxx>
Date: Thu, 17 Jan 2002 06:39:37 -0800 (PST)
xsl fo zero width space
Thank you so much, Andrew and Joerg.  Both of you
provide a solution for my problem.

Joerg, by make data fit in a table cell, I mean to
make data wrap at some point so that it always is in
the column.  My current problem is the data just go
into the next column, and cover the next column value.
 That's something I want to prevent.

Either to use substring() to force the long string to
wrap or put a zero width space works for me.   

Do appreciate your help.


--- Joerg Pietschmann <joerg.pietschmann@xxxxxx>
> yan bai <bytj@xxxxxxxxx> wrote:
> > The table has 7 columns.  One of the columns may
> > contain a string like
> > "ABCD_XXX_YYY_D1_ZZZ_DDD_DD0_DA0".  This column
> will
> > expand into the next column "col_2" and make the
> data
> > in the "col_2" column ineligible.
> That's quite obvious. What i'd like to know is what
> you
> want to have instead.
> I'll use the following FO snippet as example:
>   <fo:table>
>     <fo:table-column column-width="20mm"/>
>     <fo:table-column column-width="20mm"/>
>     <fo:table-body>
>       <fo:table-row>
>         <fo:table-cell>
> <fo:block>ABCD_XXX_YYY_D1_ZZZ_DDD_DD0_DA0</fo:block>
>         </fo:table-cell>
>         <fo:table-cell>
>           <fo:block>test</fo:block>
>         </fo:table-cell>
>       </fo:table-row>
>     </fo:table-body>
>   </fo:table>
> For solutions at the FO-level, you can try
> hyphenation:
>   <fo:block hyphenate="true"
> This works somehow. FOP (0.20.2) will spout some
> errors ([ERROR]: >)
> which indicate repeated area overflow, you can
> ignore them. You might
> want to customize the hyphenation further, look at
> the 
> for possibilities. Of course, hyphenation works best
> if the long words
> are really words. If they are artificial constructs
> as your example
> suggests (sort of product ids or something similar),
> hyphenation
> might not be what you want.
> The other solution, having long strings clipped at
> the cell boundary,
> apparently is not possible with FOP as it requires
> not yet implemented
> features.
> There are also some possible solutions at the XSLT
> level, in case you
> generate the FO this way.
> - You could insert a zero width space (&#8203;)
> into long strings,
>  for example by replacing "_" by "_&#8203;". The FO
> processor is able
>  to wrap the string at the zero width spaces if
> needed, and the spaces
>  go unnoticed where no wrap is necessary. This gives
> you some control
>  where the string can be wrapped but will of course
> fail if long
>  substrings without an inserted zero width space
> remain. Unfortunately,
>  this sort of replacement is not all that easy to do
> in XSLT, look at
>  or the archives of this list for some hints. You
> might want to combine
>  this with a tokenizer in order to process only long
> words, here
>  might get you started (use spaces instead of
> commas, of course).
>  Alternatives are to insert a zero width space after
> each character, or
>  after each N characters, where N characters can be
> expected to fit
>  into the cell.
> - You could simply cut off long strings after N
> characters. Use a
>  tokenizer to get the words in your text and use
> substring() on them.
> - Format the text yourself in order to ensure lines
> are no longer than
>  N characters, either clipping or wrapping long
> strings in the process.
>  You'll have to build a recursive template solution
> along the lines
>  of the string replace mentioned above. I'm sure the
> list archive
>  already contains code which could be reused.
> Be aware that the possible solutions which include
> "N character" may
> result in somewhat unpleasant appearance if you use
> a proportional
> font, as N has to be a preset constant.
> If you are after calculating column withs in order
> to fit the data
> into the cells, well, this can't currently be done
> in FO. For a
> solution at the XSLT level, you may use a tokenizer
> as mentioned
> above to get the words in the texts and try to
> derive the necessary
> column width from the string length of the words. In
> case you use
> proportional fonts you'll run into the same
> difficulties as in some
> of the possibilities mentioned above because you'll
> need font metrics
> for exact calculations, and there is no easy way in
> XSLT to retrieve
> them.
> Now: What do you actually mean by "fit data into a
> table cell"?
> J.Pietschmann
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list

Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.