[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|