[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to avoid applying templates several times to t
Hi Joakim, > Sadly, it didn't solve all my problems. Your solution still doesn't > consider other special templates that have to apply to descendants > of the ATLAS node. In my solution, the templates are applied in 'copy' mode, with the default template being: <xsl:template match="*" mode="copy"> <xsl:param name="attr" /> <xsl:if test="not(@ATTR) or @ATTR = $attr"> <xsl:copy> <xsl:copy-of select="@*" /> <xsl:apply-templates mode="copy"> <xsl:with-param name="attr" select="$attr" /> </xsl:apply-templates> </xsl:copy> </xsl:if> </xsl:template> If you want to override that default template, then you need to add another template, still in copy mode, that matches the nodes that you want to override it for, so for example: <xsl:template match="CARE" mode="copy"> <xsl:param name="attr" /> <!-- adding wrap tags --> <CAREWRAP> <xsl:copy> <xsl:copy-of select="@*"/> <xsl:apply-templates mode="copy"> <xsl:with-param name="attr" select="$attr" /> </xsl:apply-templates> </xsl:copy> </CAREWRAP> </xsl:template> Note here that I am still passing the $attr parameter through the templates, so that if a CARE element has a child that has an @ATTR attribute that is *not* equal to the value that you're using for the particular copy then it will not be copied. However, I think that if you already have all the templates that you want for certain descendants of ATLAS, then you're probably not concerned about the @ATTR attribute on those descendants or their descendants - is that right? If so, I doubt you want to go through adding 'copy' modes to all of them, so you're better off using Jarno's solution, which didn't use modes. 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
|