This is the mail archive of the
docbook-apps@lists.oasis-open.org
mailing list .
Re: [docbook-apps] Re: [docbook] How can I add another chunk navigationlink?
- From: Paul Heinlein <heinlein at madboa dot com>
- To: Bob Stayton <bobs at sagehill dot net>
- Cc: DocBook Apps <docbook-apps at lists dot oasis-open dot org>, Sheldon Plankton <sheldonplankton at yahoo dot com>
- Date: Tue, 24 Aug 2004 09:15:55 -0700 (PDT)
- Subject: Re: [docbook-apps] Re: [docbook] How can I add another chunk navigationlink?
- References: <20040823201423.1164.qmail@web53505.mail.yahoo.com><56e401c489f3$be023350$6401a8c0@toshiro>
On Tue, 24 Aug 2004, Bob Stayton wrote:
> [I'm moving this over to docbook-apps since it deals with stylesheets]
>
> One way to do what you want is to put the call to 'href.target'
> inside a variable, then use substring-before() to clip off the
> '.html', and then append the '.pdf'. This assumes the PDF is always
> in the same place as the HTML, of course.
>
> <xsl:variable name="href.orig">
> <xsl:call-template name="href.target">
> <xsl:with-param name="object" select="."/>
> </xsl:call-template>
> </xsl:variable>
>
> <xsl:value-of select="substring-before($href.orig, '.html')"/>
> <xsl:text>.pdf</xsl:text>
I have a generic utility template that does this, since I find myself
doing this operation quite often:
<!-- transform filename -->
<xsl:template name="util.filenamechange">
<xsl:param name="filename"/>
<xsl:param name="oldsuffix"/>
<xsl:param name="newsuffix"/>
<xsl:variable name="base">
<xsl:value-of select="substring-before($filename, $oldsuffix)"/>
</xsl:variable>
<xsl:value-of select="concat($base, $newsuffix)"/>
</xsl:template>
True, you've got to call it with three params, which might be a bit
unwieldy, but it has the virtue of being somewhat easy to understand
when called from another template, e.g.,
<a>
<xsl:attribute name="href">
<xsl:call-template name="util.filenamechange">
<xsl:with-param name="filename" select="."/>
<xsl:with-param name="oldsuffix" select="'.xml'"/>
<xsl:with-param name="newsuffix" select="'.html'"/>
</xsl:call-template>
</xsl:attribute>
<xsl:value-of select="$info/title"/>
</a>
--Paul Heinlein <heinlein@madboa.com>