This is the mail archive of the xsl-list@mulberrytech.com mailing list .


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

Re: ambiguous templates


Lee,

> The below gives me ambiguity error, fine. So how do I implement templates
> that are increasing specialised?

Unfortunately, this is something that you have to do by hand.  You
need to associate a priority with each template using the 'priority'
attribute.  Make your specialised templates have a higher priority
than your general ones, and you'll get the effect you want:

<xsl:template match="st" priority="1">...</xsl:template>
<xsl:template match="sec/st" priority="2">...</xsl:template>
<xsl:template match="bdy/sec/st" priority="3">...</xsl:template>

The only other option is to have a general template that uses
conditional processing to decide what to do. This is an ugly method,
but it has the advantages of not making you keep up with all the
priorities in your stylesheet and keeping the common formatting for
the 'st' elements in the same place.

<xsl:template match="st">
  <xsl:variable name="content">
    <strong>
      <xsl:choose>
        <xsl:when test="parent::sec">
          <a name="section{parent::sec/no}">
            <xsl:apply-templates />
          </a>
        </xsl:when>
        <xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
      </xsl:choose>
    </strong>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="parent::sec/parent::bdy">
      <font size="+1">
        <xsl:copy-of select="$content" />
      </font>
    </xsl:when>
    <xsl:otherwise><xsl:copy-of select="$content" /></xsl:otherwise>
  </xsl:choose>
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

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