Re: [xsl] keeping source element after template applied?

Subject: Re: [xsl] keeping source element after template applied?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 03 Dec 2002 17:57:12 -0500
Kevin,

Apparently you're assuming that a node is "kept" or "gotten rid of" by the processor, but it isn't so. Rather, nodes in the source tree are always there -- the processor can always look at the source tree and none of it is ever thrown away. The processor's job is to *build* a result tree that starts with nothing in it (or actually, with nothing in it but a root node). What it adds to this result (the "tree" it "builds", in the topsy-turvy world of XML metaphors) depends on your stylesheet.

So your question can be reframed as "is it possible to apply more than one template to a node", leaving out whether the element is "removed". (It'll never be removed from the source tree. Whether a *copy* of it *ever* appears in the result, is up entirely to you. By default, the processor will copy text nodes, but not elements as such.)

If you could be more specific, or (better) show us a bit of code, we could make a better guess as to whether you would be best off:

(a) matching your element with a template that does something, then applies a second template, in another mode, to its own context node (thereby getting two different templates applied);
(b) using <xsl:call-template> to call a template by name from your matching template;
(c) splitting your stylesheet into pieces and using <xsl:apply-imports/>, which allows one stylesheet to invoke a "backup" template of a lower import precedence (matching the same element);
(d) something altogether different....


Cheers,
Wendell

At 05:41 PM 12/3/2002, you wrote:
Hi,

I have a document in which I'd like some elements to remain intact, after I've applied a transformation template to them.

The reason is that there's more than transformation that has to be made, by other matching templates, to this element before it can be removed.

I want to do:

xsl template match="myElement"
do one complex thing

xsl template match="myElement"
do another complex thing, and let element be removed

I'm not seeing any provision for this, is there a way to do so?

thanks
Kevin


======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread