Subject: RE: [xsl] How do you apply templates ONLY to the direct children of an element/node? From: "Firas Darweesh" <firas@xxxxxxxxx> Date: Tue, 26 Aug 2003 18:07:01 +0400 |
Hi: Try this <xsl:apply-templates select="node()[not(self::*)]"/> Just will select the node... I wish this help Firas darweesh -----Original Message----- From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Borislav Stoyanov Sent: Tuesday, August 26, 2003 5:38 PM To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx' Subject: RE: [xsl] How do you apply templates ONLY to the direct children of an element/node? > > How do you apply templates ONLY to the direct children of an > > element/node, > > supposed you dont know their name? > > <xsl:apply-templates select="*"/> > > which is an abbreviation of > > <xsl:apply-templates select="child::*"/> > > > What if there is no > > matching template, > > why are grandchildren also matched? > > Because the build-in default template is used, which in this case is > > <xsl:template match="* | /"> > <xsl:apply-templates select="node()"/> > </xsl:template> > Actually I know this but it is NOT ONLY for the DIRECT children but also for their grandchildren and so on IF there is no specified matching template for <unknown-element>. My idea is that if the xsl-transformer finds an element for which it is not defined a template it just skips it and don't go into this element's children? > Let > > <element-1> > > <unknown-element> > > .... > > </unknown-element> > > <element-1> > > be the xml file to be transformed. > > > > Now you got the following transforming rule: > > <xsl:template match="element-1"> > > <xsl:apply-templates select="*"/> > > </xsl:template> > > > > What I expect is that if an xsl <unknown-element> template rule is not > > available nothing should happen. However I get apply-templates on the > > elements contained in <unknown-element>...</unknown-element>. Why does it > > happen and how can I achieve to apply the templates ONLY to the direct > > children and avoid the implied apply-template rules to the grandchildren > > and so on? > > Override the default rule with e.g. > > <xsl:template match="*"/> Thats not that simple if you have 200 other templates/cases somewhere else. Best regards, XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How do you apply template, Borislav Stoyanov | Thread | [xsl] <xsl:param> or <xsl:variable>, Abhijit Junnare |
Re: [xsl] Merging two xml files, David Mitchell | Date | RE: [xsl] How do you apply template, Michael Kay |
Month |