[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: ambiguous templates

Subject: Re: ambiguous templates
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 7 Nov 2000 18:40:08 +0000
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.