[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] How do you apply templates ONLY to the direct children of an elem ent/node?


Subject: [xsl] How do you apply templates ONLY to the direct children of an elem ent/node?
From: Borislav Stoyanov <BStoyanov@xxxxxxxxx>
Date: Tue, 26 Aug 2003 13:32:22 +0100

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



Current Thread
Keywords