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

Re: Match node() with exception

Subject: Re: Match node() with exception
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 31 Aug 2004 09:53:01 +0100
match node
Hi Karl,

> This is not working for me:
>
> <xsl:apply-templates select="node()[not(/SchemaVersion)]"/>
>
> I have the node "SchemaVersion" which I care to NOT display. What am
> I doing wrong?

You are selecting all the nodes that do not live in a document where
<SchemaVersion> is the root node. The path "/SchemaVersion" returns a
node when the <SchemaVersion> element is the root node. The expression
"not(/SchemaVersion)" returns true when there isn't such a node.

Given that the <SchemaVersion> element is a child of the current node
at the point you're using the <xsl:apply-templates> instruction, you
should use:

  <xsl:apply-tempaltes select="node()[not(self::SchemaVersion)]" />

self::SchemaVersion selects the node itself if it is a <SchemaVersion>
element. "not(self::SchemaVersion)" returns true only if the context
node isn't a <SchemaVersion> element. So
"node()[not(self::SchemaVersion)]" selects only those nodes that
aren't, themselves, <SchemaVersion> elements.

Alternatively, you could select all nodes with:

  <xsl:apply-templates select="node()" />

or, since the select attribute defaults to "node()", simply:

  <xsl:apply-templates />

and then have a template that does nothing when the <SchemaVersion>
element is processed:

<xsl:template match="SchemaVersion" />

Cheers,

Jeni

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

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.