This is the mail archive of the
docbook@lists.oasis-open.org
mailing list for the DocBook project.
Decorating a template call?
- From: Michael Schuerig <schuerig at acm dot org>
- To: docbook at lists dot oasis-open dot org
- Date: Wed, 01 Jan 2003 07:25:05 +0100
- Subject: DOCBOOK: Decorating a template call?
- Organization: -
I wanted to be able to have a way to make an author's name into a link
and so added a url attribute to the author element. To process this new
attribute, I had to customize the person.name template. The real work
is still done in a slightly changed copy of the original template. The
only change is the new name. Works fine, but the code duplication is
not pretty:
<xsl:template name="person.name">
<xsl:param name="node" select="."/>
<xsl:choose>
<xsl:when test="$node/@url">
<a href="{$node/@url}">
<xsl:call-template name="person.name.original">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="person.name.original">
<xsl:with-param name="node" select="$node"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="person.name.original">
<!-- ...duplicated original template... -->
</xsl:template>
The duplication could be avoided if there was an indirection in the
docbook stylesheets. But that doesn't seem right, either.
Michael
--
Michael Schuerig If at first you don't succeed...
mailto:schuerig@acm.org try, try again.
http://www.schuerig.de/michael/ --Jerome Morrow, "Gattaca"