W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2007

XPathNSResolver issues

From: Joćo Eiras <joao.eiras@gmail.com>
Date: Thu, 11 Oct 2007 17:48:28 +0100
To: "www-dom@w3.org" <www-dom@w3.org>
Message-ID: <op.tz1ky2ohjz3wb9@mors.wag54gs>


Since, and www-dom-xpath list is inactive, I sent this e-mail to this list.

Please, consider the following xml fragment

   <r:root xmlns:r="http://www.example.com/"><r:element/></r:root>

I can query the element "element" using the xpath dom with the following  
xpath expression


using the following line of code


This sould work ok.

Now, consider I have the same testcase, but no prefixes in the xml source

   <root xmlns="http://www.example.com/"><element/></root>


This will NOT return anything.
The only possible way is to have the prefixes in the xpath expression, and  
build a custom nsresolver.

This is a issue, severe from my point of view, as you cannot reuse the  
same logic to retreive those nodes.
We need to find a way to drop the prefixes and still being able to select  
the same nodes.
Note: In the problem I'm trying to resolv,I cannot change the xml and the  
xpath expressions, only the nsresolver.

The xpath dom spec clearly left out this use case after specifing that the  
result of passing null or the empty string to lookupNamespaceURI should be  
undefined. How would then one query the default namespace ?
I suggest the following: if there's no passed nsresolver to evaluate()  
keep the current behaviour.
If there's a nsresolver, then node names without prefix in the expression  
are in the namespace returned by loopupNamespaceURI with a null or empty  
string parameter. This would be backwards compatible with the current  
spec, because applications currently do not passed empty string or nulls  
to loopupNamespaceURI, so this would be an harmless extension.

Thank you.
Received on Thursday, 11 October 2007 16:56:03 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:13 UTC