Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

xsl break word

Posted on 2010-08-16
28
557 Views
Last Modified: 2013-11-18
i have 2 columns in a row.  Second column holds text. Text can be sentence or a single long word. IIf it is a single long word it tries to occupy first cell. I want the long word to break up and wrap.
please let me know if you have any suggestions.
0
Comment
Question by:mahalasa
  • 16
  • 9
  • 2
  • +1
28 Comments
 
LVL 51

Expert Comment

by:HainKurt
ID: 33447007
wrap the second one in "a long text here bla bla bla...."
0
 

Author Comment

by:mahalasa
ID: 33447015
i dint get u..pls elaborat
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33447024
There is a multitude of options.
So I have a couple of questions for you:
- XSLT1 or XSLT2
- Which XSLT processor, can that change?
- How do you want to break, every n characters, is n a parameter, how do you intend to tell the size based on the cell width?
- HTML or PDF, or... have you considered CSS wrapping options such as word-wrap (IE only)
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 11

Expert Comment

by:kmartin7
ID: 33447037
Is this XSL:FO?
0
 

Author Comment

by:mahalasa
ID: 33447040
basically pdf is generated. Yes i have tried word wrap no use.
0
 

Author Comment

by:mahalasa
ID: 33447045
yes xsl;block
0
 

Author Comment

by:mahalasa
ID: 33447071
any expert in xsl?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33447097
If it is xsl:fo, and it is long words and you processor can't deal with hyphenation correctly, then I assume that the best alternative you have is adding a zerowidth space between each letter
easily done in XSLT2, some recursion in XSLT1.
Would that work for you?
I assume you have tried the wrap options of FO
0
 

Author Comment

by:mahalasa
ID: 33447098
i have seen that 24 characters can fit in without issues. i need to wrap text to next line for word greater than 24 characters.
0
 

Author Comment

by:mahalasa
ID: 33447111
wrap option works only for sentence.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33447114
> any expert in xsl?

well, you have two here already?
Not enough?
Don't expect miracles if you ask half questions
0
 

Author Comment

by:mahalasa
ID: 33447123
how do we add zero width space?
0
 

Author Comment

by:mahalasa
ID: 33447136
:-)
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33447158
​
0
 

Author Comment

by:mahalasa
ID: 33447170
wat would this zero width space do?
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33447193
well, visually you would still have one word, so your FO processor will not show the character.
For the processor however the word is no longer a word, but a sequence of characters with spaces in between, so wrapping will work as you please
0
 

Author Comment

by:mahalasa
ID: 33447218
This seems like resolving my issue. can you give me an example to use it with code snippet.

Thank a lot :-)
0
 
LVL 11

Expert Comment

by:kmartin7
ID: 33447233
Depending on FO processor, have you tried placing the text within each cell within a block, then use the 'wrap-option" attribute set to "wrap"?
0
 

Author Comment

by:mahalasa
ID: 33447241
yes, its already within a block :-(
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33447247
Which processor have you used?
Are you sure you have exposed the wrap options in the block?
0
 

Author Comment

by:mahalasa
ID: 33447266
i am not sure abt the processor :-( i am new to xsl . yes i have tried wrap option. my pdf work absolutely fine for long sentence with proper wrapping
0
 

Author Comment

by:mahalasa
ID: 33447273
can u give me a code snippet which uses zero width spacing
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33447294
there are two processors, one for XSLT and one for XSL:FO
It makes sense that you know both of the processor brands and possibilities
Processors have specific implementations, so it can bite you if you don't have a clue

I will assume you have XSLT1 for the zero width stuff
0
 

Author Comment

by:mahalasa
ID: 33447300
Hi Gertone, i need one more help
do u know abt itext?
0
 

Author Comment

by:mahalasa
ID: 33447312
any code snippet using it would be really helpful
0
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 33447355

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="1.0">
    <xsl:template match="/">
        <xsl:variable name="test-string">
            <xsl:text>thisisaverylongwordandmyhyphenatorchoquesonit</xsl:text>
        </xsl:variable>
        <block>
            <xsl:call-template name="add-zero-width">
                <xsl:with-param name="str" select="$test-string"/>
            </xsl:call-template>
        </block>
    </xsl:template>
    <xsl:template name="add-zero-width">
        <xsl:param name="str"/>
        <xsl:value-of select="substring($str, 1, 1)"/>
        <xsl:text>&#8203;</xsl:text>
        <xsl:if test="string-length($str) > 1">
            <xsl:call-template name="add-zero-width">
                <xsl:with-param name="str" select="substring($str, 2)"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 

Author Closing Comment

by:mahalasa
ID: 33447373
Great response. I am really thankful.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 33448254
welcome
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question