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

quick XPath question: finding /a/b/c with a default namespace

  • From: James Strachan <james_strachan@y...>
  • To: xml-dev@l...
  • Date: Fri, 27 Jul 2001 10:23:59 +0100

dom4j xpath namespace
This XPath question recently came up on the dom4j-user discussion list, I
wondered if anyone around here knew the answer. (Strictly speaking maybe
XPath questions should be sent to the XSL mail list?)

Given

<a xmlns="dummyNamespace">
  <b>
    <c>Hello</c>
  </b>
</a>

Should the path

    /a/b/c

find the <c> element?

From 2.3 of the XPath spec

"A QName in the node test is expanded into an expanded-name using the
namespace declarations from the expression context. This is the same way
expansion is done for element type names in start and end-tags except that
the default namespace declared with xmlns is not used: if the QName does
not have a prefix, then the namespace URI is null (this is the same way
attribute names are expanded). It is an error if the QName has a prefix
for which there is no namespace declaration in the expression context."

So the default namespace is not used and none of the QNames in the document
or the path have namespace prefixes, so the namespace URI is null for all
the QNames.

So /a/b/c should find <c> because all the namespace URIs match (they are all
null)?

James



_________________________________________________________

Do You Yahoo!?

Get your free @yahoo.com address at http://mail.yahoo.com




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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.