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

Re: how to select elements in a given namespace?

Subject: Re: how to select elements in a given namespace?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 17 Mar 2003 20:40:32 +0000
select element with namespace
Hi Robert,

> if i want to select all nodes in a given namespace ("auth"), it
> appears i can use:
>
>   //namespace::auth

That will select all the *namespace*nodes* named "auth". Namespace
nodes are nodes that represent a prefix-namespace binding. Such a
namespace node will exist on every element within the scope of the
xmlns:auth="..." namespace declaration.

If you want to select all the elements in the namespace associated
with the prefix 'auth', use:

  //auth:*

All attributes in that namespace with:

  //@auth:*

Note that the 'auth' namespace must be declared in the stylesheet
(or in whatever context you're selecting the nodes). A stylesheet will
not automatically pick up on the fact that the namespace is declared
in the XML document.

> so what is the XPath expression to match, say, the <last-name>
> elements within this namespace?

XPath expressions don't match elements, they select them. If you want
to select the last-name element in the 'auth' namespace, use:

  //auth:last-name

or, better:

  /auth:author/auth:last-name

To *match* the auth:last-name element with an XSLT pattern, you can
use:

  auth:last-name

Note that in your example, the <last-name> element is not in the
namespace associated with the 'auth' prefix since it does not have a
prefix and there is no default namespace declaration. In your example,
only the <auth:author> element is in the 'auth' namespace.
  
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.