forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Wheller <s...@inwords.co.za>
Subject Help FOR-308
Date Tue, 05 Oct 2004 07:39:28 GMT

I want to add support for xref to docbook2document.xsl so I created the 
following template:

START ~~~~~~~~~~~~~~~~
<xsl:template match="xref">
        <xsl:param name="linkend">
            <xsl:value-of select="@linkend"/>
        </xsl:param>
        <xsl:param name="endterm">
            <xsl:value-of select="@endterm"/>
        </xsl:param>
        <xsl:param name="linkendvalue">
            <xsl:if test="$linkend">
                <xsl:value-of select="//*[@id=$linkend]/title"/>
            </xsl:if>
        </xsl:param>
        <xsl:param name="endtermvalue">
            <xsl:if test="$endterm">
                <xsl:value-of select="//*[@id=$endterm]"/>
            </xsl:if>
        </xsl:param>
        <xsl:choose>
            <xsl:when test="//xref[not(@endterm)]">
                <xsl:element name="link">
                    <xsl:attribute name="href">
                        <xsl:text>#</xsl:text>
                        <xsl:value-of select="$linkend"/>
                    </xsl:attribute>
                    <xsl:value-of select="$linkendvalue"/>
                </xsl:element>
                <xsl:apply-templates/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:element name="link">
                    <xsl:attribute name="href">
                        <xsl:text>#</xsl:text>
                        <xsl:value-of select="$linkend"/>
                    </xsl:attribute>
                    <xsl:value-of select="$endtermvalue"/>
                </xsl:element>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
END ~~~~~~~~~~~~~~~~

The template handles two xref conditions. 
1. Where xref has only a @linkend. 
2. Where xref has @linkend and @endterm
(see itemized list below)

START ~~~~~~~~~~~~~~~~
<itemizedlist spacing="compact">
            <listitem>
                <para>
                    <xref linkend="single-source"/>
                </para>
            </listitem>
            <listitem>
                <para>
                    <xref linkend="collaboration" 
endterm="title-collaboration"/>
                </para>
            </listitem>
        </itemizedlist>
END ~~~~~~~~~~~~~~~~

These point to elements that have @id
<sect2 id="single-source">
            <title id="title-single-source">Single-sourcing</title>
<para>Text</para>
</sect2>

<sect2 id="collaboration">
            <title id="title-collaboration">Collaborative authoring</title>
<para>Text</para>
</sect2>

The first xref in the itemizedlist does not say where the value of the link 
should come from.

The second does, by way of the endterm.

This enables the text for a link to be obtained from any element that has an 
@id

My template creates the links, but does not work because forrest is adding its 
own anchor @id to sections. So the link is displayed with the right text, but 
goes nowhere since the target does not exist in the rendered html document.

You can test this by adding the template above to docbook2document.xsl
Add the attached docbook test file to xdocs and to site. It will demo the 
problem.

~~ 
Sean Wheller
Technical Author
sean@inwords.co.za
http://www.inwords.co.za

Mime
View raw message