Subject: Re: [xsl] How to avoid applying templates several times to the same descendant From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 9 May 2001 09:14:52 +0100 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to avoid applying tem, Joakim Norlov | Thread | Re: [xsl] How to avoid applying tem, Joakim Norlov |
RE: [xsl] XSL Processors supporting, Seaborne, Mark | Date | [xsl] Problem of memory allocation , Borca, Olivier |
Month |