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

Re: difference between select="*" and select="node()"

Subject: Re: difference between select="*" and select="node()"
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 8 Apr 2002 12:44:36 +0100
between select
Hi Karthik,

> it's behaving the same way for me :-(
> am using Oreilly's XSLT to learn XSLT.
> It says that node() selects the attribute as well in addition to the text
> nodes.
> But still my attribute values do not get printed.
> The book also mentions that attribute needs to be selected
> explicitly to apply the default rule for attributes.
> If node() does that then why does'nt it print?

When you do:

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

it's short for:

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

In other words, it selects all the *child* nodes of the current
element. Attributes don't count as children, so you don't select any
attributes.

To select attributes, you have to use the attribute axis:

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

which is more commonly shortened to '@':

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

Usually you use the node test * rather than the node test node() to select attributes

  <xsl:apply-templates select="@*" />

Technically, * matches the principal node type for whatever axis you
use. The only nodes that you can find along the attribute axis are
attributes, so doing @* is the same as doing @node().

If you want to select child nodes and attributes at the same time, use
the union operator:

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

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.