1

I have a lot of numbers in a table that are hyphenated. But when there is a number containing a "/" character, I want to hyphenate after that... if it is necessary.

Is there a attribute for this?

XML Example:

<ptxt>123567/89012345</ptxt>

Split after "/" if necessary.

Thanks!

mzjn
  • 48,958
  • 13
  • 128
  • 248
  • Im generating XSL-FO (then Antenna House to PDF). – user1065283 Dec 20 '11 at 14:07
  • Does Antenna House have any kind of configuration for hyphenation? – khachik Dec 20 '11 at 14:32
  • Did you consider inserting unicode soft hyphen characters? http://en.wikipedia.org/wiki/Soft_hyphen – grtjn Dec 20 '11 at 14:35
  • Antenna House can read a custom xml file, and there you can specify all the words you want to be hyphenate in a special way; for example you can write "long-word", so the word "longword" will be hyphen after "long" and before "word" if necessary. – user1065283 Dec 20 '11 at 14:49
  • But I dont want to add every number in the hyphenation-xml-file. :P – user1065283 Dec 20 '11 at 14:49
  • @grtjn: I can not edit the xml-file, I want to automatise the PDF creation procedure. Thanks anyway! – user1065283 Dec 20 '11 at 14:54
  • @user1065283, I guess that this actually is a line wrapping issue rather than a hyphenation issue. Hyphenation is supposed to be applied to real words, and that is not what you have. See this answer for some suggestions: http://stackoverflow.com/a/4533760/407651. – mzjn Dec 20 '11 at 14:56

2 Answers2

2

You can add a word joiner character (&#8288;) before your /. One way of doing this with XSLT could be :

<xsl:variable name="test" select="'123/456'"/>
<xsl:choose>
    <xsl:when test="contains($test,'/')">
        <xsl:value-of select="concat(substring-before($test,'/'),
            '&#8288;','/',substring-after($test,'/'))"/>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="$test"/>
    </xsl:otherwise>
</xsl:choose>        
Vincent Biragnet
  • 2,950
  • 15
  • 22
0

A shorter way is: <xsl:copy-of select="replace($test,'/','&#8288;/')"/>

roman
  • 1
  • 1