|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: How do you apply templates ONLY to the direct chil
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: 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
|
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
|

Cart








