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] | [List Home]


Subject: Re: [docbook-apps] Re: [docbook] How can I add another chunk navigationlink?


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>


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