OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]

Subject: RE: DOCBOOK-APPS: Re: A good tag for representing a very long URL

I thought of a way to get around the limitation that renderer's don't
support zero-width spaces. Use a space with a font-size of zero:

		  character=" "

The code to import into your customization layer is pasted at the bottom
of this message (I think it also makes the hot text blue). It still
smells too much like a hack to include in the standard xsls. The spaces
really are there, so if you cut-and-paste a url, the url is useless
(e.g. o a s i s . o r g ), but the text in the pdf is hot anyway and the
url is only there because a pdf could be printed. It would be tempting
to use the trick for other elements that contain stuff that can't be
hyphenated but should wrap (e.g. code), but there you might have users
frustrated that they can't cut and paste your code samples.

Note the actual xsl that does the interspersing is Julien Letessier's
(and I think he was working from something Nikolai Grigoriev posted on
the xsl-fo list). I also changed it so that it doesn't start
interspersing spaces till after the 15th character (so you don't end up
with "h[linebreak]ttp://..." I suppose it could be made so that spaces
aren't interspersed in the last few characters of the url either. 


> -----Original Message-----
> From: Norman Walsh [mailto:ndw@nwalsh.com]
> Sent: Sunday, January 27, 2002 1:04 PM
> To: docbook-apps
> Subject: DOCBOOK-APPS: Re: A good tag for representing a very long URL
> / David Cramer <dcramer@broadjump.com> was heard to say:
> | Also take a look at this post:
> |
> | 
> http://lists.oasis-open.org/archives/docbook-apps/200201/msg00267.html
> This post suggests zero-width spaces instead of discretionary hyphens.
> (Actually, it uses hair-width spaces instead of zero-width spaces,
> which I think is a bug, but nevermind).
> Unfortunately, using zero-width spaces doesn't work in XEP, 
> FOP, or PassiveTeX.
> Using discretionary hyphens works in XEP and PassiveTeX, but 
> not in FOP
> So I think I'll stick with discretionary hyphens for the 
> moment and leave
> an option to turn it off if desired.
>                                         Be seeing you,

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

    <!-- colored links with invisible spaces interspersed so that long
urls will wrap -->
    <xsl:template match="ulink">
        <fo:basic-link external-destination="{@url}"
                <xsl:when test="count(child::node())=0">
                    <xsl:value-of select="@url" />
                    <xsl:apply-templates />
        <xsl:if test="count(child::node()) != 0">
            <fo:inline hyphenate="true">
                <xsl:text> (</xsl:text>
                <xsl:value-of select="substring(@url,0,15)"/>
                <xsl:call-template name="intersperse-with-zero-spaces">
                    <xsl:with-param name="str"

    <!-- Actual space intercalation: recursive -->
    <xsl:template name="intersperse-with-zero-spaces">
        <xsl:param name="str"/>
        <xsl:variable name="spacechars">

        <xsl:if test="string-length($str) &gt; 0">
            <xsl:variable name="c1"
                    select="substring($str, 1, 1)"/>
            <xsl:variable name="c2"
                    select="substring($str, 2, 1)"/>

            <xsl:value-of select="$c1"/>
            <xsl:if test="$c2 != '' and
                    not(contains($spacechars, $c1) or
                    contains($spacechars, $c2))">
		  character=" "

            <xsl:call-template name="intersperse-with-zero-spaces">
                <xsl:with-param name="str" select="substring($str, 2)"/>


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]

Powered by eList eXpress LLC