This is the mail archive of the docbook@lists.oasis-open.org mailing list for the DocBook project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Decorating a template call?


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"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]