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: XSL Hacking problems


(This was about letting URLs hyphenate in DocBook FO output (e.g. PDF with
Fop). Should work anywhere.)

le 13/01/02 18:57, David Cramer écrivit:

> Julien,
> If you figure out the first one, let me know. The thread
> http://groups.yahoo.com/group/XSL-FO/messagesearch?query=forcing%20line%
> 20breaks might be relevant, though I'm not sure if that idea ended up
> working for the participants and it may be xep centered.

Hey hey. Thanks for the link. I had to hack a little around, but it finally
works. The drawback is that though URLs get hyphenated, character spacing is
increased in the URLs...

I can personnaly can get along with it, in fact I pretty much like it -- it
makes URLs stand out from the rest of the text.

Enough talking, here's the hack for XSL 1.48 (it inserts hairline-spaces
between every character in an URL): add it in your XSL driver file.

The first part is a (slightly) modified version of a part of fo/xref.xsl;
the second is almost exactly like the hack created by Nikolai Grigoriev
found on Yahoo! group XSL-FO.

--- START XSL CODE ---
    <!-- colored / hyphenated links -->
    <xsl:template match="ulink">
        <fo:basic-link external-destination="{@url}"
                xsl:use-attribute-sets="xref.properties"
                color="#0000AA">
            <xsl:choose>
                <xsl:when test="count(child::node())=0">
                    <xsl:value-of select="@url" />
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates />
                </xsl:otherwise>
            </xsl:choose>
        </fo:basic-link>
        <xsl:if test="count(child::node()) != 0">
            <fo:inline hyphenate="true">
                <xsl:text> (</xsl:text>
                <!--<xsl:value-of select="@url"/>-->
                <xsl:call-template name="intersperse-with-zero-spaces">
                    <xsl:with-param name="str" select="@url"/>
                </xsl:call-template>
                <xsl:text>)</xsl:text>
            </fo:inline>
        </xsl:if>
    </xsl:template>

    <!-- Actual space intercalation: recursive -->
    <xsl:template name="intersperse-with-zero-spaces">
        <xsl:param name="str"/>
        <xsl:variable name="spacechars">
            &#x9;&#xA;
            &#x2000;&#x2001;&#x2002;&#x2003;&#x2004;&#x2005;
            &#x2006;&#x2007;&#x2008;&#x2009;&#x200A;&#x200B;
        </xsl:variable>

        <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))">
                <xsl:text>&#x200A;</xsl:text>
            </xsl:if>

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

Cheers,
-- 
Julien "mezis" LETESSIER  snail-mail:              tel: +33 6 63 19 67 11
ENSIMAG student           36 cours Berriat         ICQ# 109936509
second year               38000 Grenoble - FRANCE  mail: mezis@online.fr



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


Powered by eList eXpress LLC