commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lansing, Jeff" <jlans...@systechnologies.com>
Subject [JXPATH] No value for xpath with default namespace prefix
Date Mon, 28 Feb 2005 17:48:53 GMT
Commons-jxpath-1.2 does not seem to handle the default namespace prefix correctly.
 
>From the documentation:
 
XPath matches qualified names (QNames) based on the namespace URI, not on the prefix. Therefore
the XPath "//foo:bar" may not find a node named "foo:bar" if the prefix "foo" in the context
of the node and in the execution context of the XPath are mapped to different URIs. Conversely,
"//foo:bar" will find the node named "biz:bar", if "foo" in the execution context and "biz"
in the node context are mapped to the same URI.
 
The way to do this is evidently to register "foo", as in: JXPathContext.registerNamespace("foo",
"biz's namespace URI"). 
 
But this does not work for the prefix "", as in JXPathContext.registerNamespace("", "biz's
namespace URI").
JXPathContext.getValue("//bar") will throw  JXPathException: No value for xpath:  in this
case.
 
A similar problem (or the same underlying problem) and a suggested fix was reported in commons-user@jakarta.apache.org/2005-02/msg00117.html.
I have tried applying this fix, but it doesn't solve this problem.
 
I too have looked at the source code for JXpath, and I suspect the real problem may be a deficiency
in the parser grammar.
 
Thanks,
 
Jeff

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message