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

Re: Fwd: Built-in *@ vs. node()

Subject: Re: Fwd: Built-in *@ vs. node()
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 16 Oct 2002 16:22:53 +0100
Re:  Fwd: Built-in *@ vs. node()
Hi Janning,

> In my XML Book "In a nutshell" it says:
> "node() matches all nodes regardless of type: attribute,
> namespace..."

It's true that the *node test* node() matches all nodes regardless of
type. However, a node test never exists alone -- it's always used
alongside an *axis*, for example:

  child::node()
  attribute::node()

The pattern "node()" is a shorthand for:

  child::node()

which matches all nodes *that are children of some other node*.
Attributes are not children of any node, therefore this pattern
doesn't match attributes. If you want to match attributes, you have to
use the attribute axis, e.g.:

  attribute::node()

or:

  attribute::*

or their shorthands:

  @node()
  @*
  
So the identity template is usually written:

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

i.e. match all nodes-that-are-children and all attributes, copy them,
and go on to process their attributes or children, if they have any.

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.