W3C home > Mailing lists > Public > www-xpath-comments@w3.org > January to March 2006

Xpath and default namespace

From: Fabrizio Fioravanti <ff@exitech.it>
Date: Tue, 14 Mar 2006 16:06:20 +0100
Message-ID: <4416DBEC.2070204@exitech.it>
To: www-xpath-comments@w3.org
CC: Gianni Grassi <g.grassi@exitech.fi.it>, Giacomo Villoresi <g.villoresi@exitech.fi.it>

Dear all,

My problem is related to the fact that is seems to be impossible with 
Xpath to define a fully qualified name of an element if I have not 
defined an alias for its namespace and I suggest to add to Xpath a way 
to set the namespace of an element also if it belong to the local 
default namespace.

This fact is evidenced by the following document

<?xml version="1.0" encoding="UTF-8"?>
<a xmlns="http://www.foo.org">
<b>my first b</b>
<b xmlns="http://www.foobar.org">another namespace</b>
<b>my second b</b>
</a>

where:
//b detects:
<b>my first b</b>
<b>my second b</b>

//*[local-name()='b'] detects all the b
<b>my first b</b>
<b xmlns="http://www.foobar.org">another namespace</b>
<b>my second b</b>

//*[name()='b'] detects all the b
<b>my first b</b>
<b xmlns="http://www.foobar.org">another namespace</b>
<b>my second b</b>

How can I get only the b in the http://www.foobar.org namespace?

It should be useful to have something like:
/a/{http://www.foobar.org}:b
since the only way seems to be to have:
/a/*[name()='b' and namespace-uri()="http://www.foobar.org"]

All the best,

Fabrizio


-- 
Eng. Fabrizio Fioravanti, Ph.D.
Project Manager - Exitech
Via delle Mantellate, 16
50129 Florence - Italy
Tel/Fax:	+39055470958
Mobile:    	+393476540182
Email: 		ff@exitech.it f.fioravanti@exitech.fi.it
IM:		Skype f.fioravanti.exitech	ICQ 296-222-577
For more information on my recent publication, Skills for Managing Rapidly Changing IT Projects, please visit www.idea-group.com
Received on Tuesday, 14 March 2006 20:18:36 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:05:55 GMT