Subject: Re: [xsl] Convert XML to Excel using XSLT Question II. From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Wed, 21 Jun 2006 14:30:34 -0400 |
In your following example:
<xsl:template match="foo"> <br/> </xsl:template>
A <br> will show up every time there is a "foo" tag, but the decendants of "foo" won't be traversed. Is this correct?
Then according to your following rule #3, when you have a template that matches a node (say node A), no matter whether there is apply-template, this node A would be traversed or applied this template anyway, but not its decendant, right?
<xsl:template match="*"> <xsl:apply-templates/> </xsl:template>
Sorry that my questions may be too naive, but all your replies did help me a lot, I feel I'm closer and closer to the goal..... :-)
1. Applying templates does *not* happen just because a template is present 2. Nevertheless, since the built-in default templates (for elements and the root) contain apply-templates instructions, the tree will be traversed completely by default in any case. 3. Yet, this default behavior is easy to override, at any level of the tree, simply by writing a template that does not contain an apply-templates instruction. This is an important, and very useful, feature of the language.
Having the instruction be explicit also allows us to:
1. Do it more than once 2. Apply templates to any nodes we like (not just the children)For your point #2, if I'd like to apply this template to its children and other nodes, how do I do this? I guess I need to give it a name and let other nodes call this template, right? Then use apply-template to its children, right? If I'm right, then can <xsl:template name = "foo" match = "foo1"> be right?
<doc> <title>My test document</title> <p>My paragraph.</p> <sec> <title>My subsection</title> <p>Hierarchies can be very useful.</p> </sec> </doc>
<xsl:template match="doc | title | p | sec"> <div class="{name()}"> <xsl:apply-templates/> </div> </xsl:template>
Cheers, Wendell
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Convert XML to Excel usin, Karen Yang | Thread | Re: [xsl] Convert XML to Excel usin, Karen Yang |
Re: [xsl] XSLT convert xml file to , Karen Yang | Date | Re: [xsl] XML data appearing in XSL, Wendy Bossons |
Month |