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

Re: deep copy and exclude some nodes

Subject: Re: deep copy and exclude some nodes
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 14 Jan 2003 09:47:16 +0000
xsl copy of exclude
Hi Joeri,

> I used
> <xsl:copy>
>   <xsl:copy-of select="@*"/>
>   <xsl:copy-of select="*[name() != 'field2']"/>
> <xsl:copy>
>
> But what when i need to remove more fields.
> I tried   <xsl:copy-of select="*[name() != 'field1' and name() !=
> 'field2']"/> but is not working.

Strange; I think that should work. You could use:

  <xsl:copy-of select="*[not(self::field1 or self::field2)]" />

(it's better to use self::field1 than name() = 'field1' because the
former is namespace-aware), but I think that in this case you should
probably apply templates to all the fields and then have empty
templates that filter out the fields that you don't want.

In other words, have an identity template like:

<xsl:template match="node() | @*">
  <xsl:copy>
    <xsl:apply-templates select="@* | node()" />
  </xsl:copy>
</xsl:template>

which will do the copying, and then have a template that does nothing
with field1 and field2 elements:

<xsl:template match="field1 | field2" />

Cheers,

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.