Re: [xsl] Convert XML to Excel using XSLT Question II.

Subject: Re: [xsl] Convert XML to Excel using XSLT Question II.
From: "Karen Yang" <kyang94@xxxxxxxxx>
Date: Wed, 21 Jun 2006 14:06:22 -0400
Thank you very much, Wendell. That explains a lot. Let me just confirm
your example to make sure that I understand correctly. Can you or
someone else please to confirm my following understanding?

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?

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?

Thanks a million!

Karen.

Current Thread