[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Copying a portion of a subtree in its entirety including

Subject: Re: Copying a portion of a subtree in its entirety including retaining the attribute and text info
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Tue, 21 Nov 2000 14:58:47 +0000
apply templates all except
Mike,

> Why am I not getting everything from 'Filter' down and why is it also
> returning items within Object2 when I'm only matching on 'Object1'. This
> is becoming extremely confusing for me.

I'm not sure why you're not getting a full copy of 'Filter', but the
reason that you're getting text from within Object2 is due to the way
the built-in templates work.

The built-in templates give arguably helpful default behaviour: they
ensure that templates are applied all the way down the document tree,
and they output any text that they find as is. Thus to ensure that
templates are *not* applied to Object2 and so on down the hierarchy
until you get to the text within it, which is then outputted, you need
to override this default behaviour.

You can do this in two ways.  Firstly, you can give a template that
says "when you see an Object2, do nothing" (an empty template):

<xsl:template match="Object2" />

Secondly, you can have something that matches a node higher up the
hierarchy (e.g. on the root node or document element) that says "only
apply templates to Object1":

<xsl:template match="Config">
  <xsl:apply-templates select="Object1" />
</xsl:template>

Of these, the latter is probably better because it stops the XSLT
Processor from having to search for templates to apply to Object2
(which can take time).  However the former option is sometimes more
practical when you want to apply templates to all except one
particular thing.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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-2013 All Rights Reserved.