[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

Subject: RE: How do you apply templates ONLY to the direct children of an element/node?
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 26 Aug 2003 15:09:01 +0100
xslt match direct children
XSLT supplies a built-in template rule that's invoked when no explicit
template rule matches a node during apply-templates. The built-in rule
does as you've discovered: it processes the grandchildren. This is often
useful, but if you don't want this behavior, just change it:

<xsl:template match="*"/>

creates a fallback template rule that does nothing.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Borislav Stoyanov
> Sent: 26 August 2003 13:32
> To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  How do you apply templates ONLY to the direct 
> children of an element/node?
> 
> 
> Hallo all,
> 
> How do you apply templates ONLY to the direct children of an 
> element/node, supposed you dont know their name? What if 
> there is no matching template, why are grandchildren also matched?
> 
> 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? Or is this a simple xsl question :)?
> 
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.