Disabling hyphenation on selected string

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Disabling hyphenation on selected string

Demis Biscaro
Hello,
I've tried to disable hyphenation on a selected string inside a
paragraph where hyphenation is enabled.
This is my document.xml sample:

<para>
    This sentence can be hyphenated anywhere.
    <phrase role="nohyph">On the opposite this sentence shouldn't be
hyphenated.</phrase>
    This sentence can be hyphenated anywhere again.
</para>

Moreover in my stylesheet for PDF output (mystyle.xsl) I've defined the
following attribute-set and template

    <xsl:attribute-set name="nohyph.prop">
        <xsl:attribute
name="keep-together.within-line">always</xsl:attribute>
        <xsl:attribute name="hyphenate">false</xsl:attribute>
    </xsl:attribute-set>

    <xsl:template match="phrase[@role='nohyph']">
        <fo:inline xsl:use-attribute-sets="nohyph.prop">
            <xsl:apply-templates/>
        </fo:inline>
    </xsl:template>

However this trick doesn't works because I see that the sentence in
phrase "nohyph" is hyphenated.

Has anyone any suggestions about this issue?

Thanks and bye,

Demis Biscaro


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Disabling hyphenation on selected string

Bob Stayton
I meant to respond to this item earlier.

The 'hyphenate' property does not apply to fo:inline elements, only block
level elements. That's what the XSL-FO 1.0 and 1.1 standards say, and I'm
not sure why that is.  There doesn't seem to be an FO mechanism to prevent
hyphenation while allowing line breaking within a phrase.  You would have to
wrap each word in an fo:inline with keep-together.within-line="always".

However, your attribute-set includes the use of
keep-together.within-line="always", so it should prevent that whole phrase
from breaking across lines, which would of course prevent hyphenation within
any of its words.  In my tests, the phrase did not break, so I'm wondering
why it did for you.

Bob Stayton
Sagehill Enterprises
[hidden email]


----- Original Message -----
From: "Demis Biscaro" <[hidden email]>
To: <[hidden email]>
Sent: Thursday, December 18, 2008 12:24 AM
Subject: [docbook-apps] Disabling hyphenation on selected string


> Hello,
> I've tried to disable hyphenation on a selected string inside a paragraph
> where hyphenation is enabled.
> This is my document.xml sample:
>
> <para>
>    This sentence can be hyphenated anywhere.
>    <phrase role="nohyph">On the opposite this sentence shouldn't be
> hyphenated.</phrase>
>    This sentence can be hyphenated anywhere again.
> </para>
>
> Moreover in my stylesheet for PDF output (mystyle.xsl) I've defined the
> following attribute-set and template
>
>    <xsl:attribute-set name="nohyph.prop">
>        <xsl:attribute
> name="keep-together.within-line">always</xsl:attribute>
>        <xsl:attribute name="hyphenate">false</xsl:attribute>
>    </xsl:attribute-set>
>
>    <xsl:template match="phrase[@role='nohyph']">
>        <fo:inline xsl:use-attribute-sets="nohyph.prop">
>            <xsl:apply-templates/>
>        </fo:inline>
>    </xsl:template>
>
> However this trick doesn't works because I see that the sentence in phrase
> "nohyph" is hyphenated.
>
> Has anyone any suggestions about this issue?
>
> Thanks and bye,
>
> Demis Biscaro
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Disabling hyphenation on selected string

Jirka Kosek
Bob Stayton wrote:

> The 'hyphenate' property does not apply to fo:inline elements, only
> block level elements. That's what the XSL-FO 1.0 and 1.1 standards say,
> and I'm not sure why that is.

Maybe because many typesetting engines are not able to control this
property on word level, but also only on paragraph level.

--
------------------------------------------------------------------
  Jirka Kosek      e-mail: [hidden email]      http://xmlguru.cz
------------------------------------------------------------------
       Professional XML consulting and training services
  DocBook customization, custom XSLT/XSL-FO document processing
------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 member
------------------------------------------------------------------


signature.asc (258 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Disabling hyphenation on selected string

Demis Biscaro
In reply to this post by Bob Stayton
Thank you, Bob and Jirka, for your notes.

Bob Stayton ha scritto:
> However, your attribute-set includes the use of
> keep-together.within-line="always", so it should prevent that whole
> phrase from breaking across lines, which would of course prevent
> hyphenation within any of its words.  In my tests, the phrase did not
> break, so I'm wondering why it did for you.
This is another mystery to be cleared up...

Thanks again,

Demis Biscaro

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]