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

Re: XPath problem with namespace attribute

Subject: Re: XPath problem with namespace attribute
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 05 Sep 2008 17:59:09 +0200
Re:  XPath problem with namespace attribute
Matthew Hailstone wrote:

It seems there is a bug in the XPath result when an empty namespace
attribute is used:

XML:
<?xml version="1.0" encoding="utf-8"?>
<One>
  <Two>
    <Three xmlns="http://www.hailstone.org/">
      <Four>
          <Five/>
      </Four>
    </Three>
  </Two>
</One>

XPath:
/One/Two/Three/Four/Five

Expected Result:
The element "Five" should be returned.

Result:
Nothing is returned.

With XPath 1.0 'foo' selects elements with local name 'foo' in no namespace. As the elements 'Three', 'Four' and 'Five' are in the namespace http://www.hailstone.org/ you need to bind a prefix to that namespace URI and use that prefix in the XPath expresssion to qualify element names. How you bind a prefix to the namespace URI depends on the XPath API you use.
Within an XSLT stylesheet you can use
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:hs="http://www.hailstone.org/"
version="1.0">
and then use e.g.
/One/Two/hs:Three/hs:Four/hs:Five



--


	Martin Honnen
	http://JavaScript.FAQTs.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.