commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 32360] - [jxpath] Default Namespace not handled correctly
Date Mon, 31 Oct 2005 07:38:42 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32360>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32360





------- Additional Comments From elharo@metalab.unc.edu  2005-10-31 08:38 -------
Let me explain how XPath handles the default namespace, since this apopears to
be at the source of all this confusion. Consider this document:

<?xml version="1.0" encoding="iso-8859-1"?>
<test xmlns="http://test">
  <child-element />
</test>

Now suppose you want to use the XPath expression //child-element

As noted this fails to find anything because it is searching for elements named
"child-element" in no namespace and this element is in a namespace. Instead we
must use a prefix in the XPath expression even though one is not used in the
original document. For example:

//foo:child-element

This prefix foo must be mapped to the namespace URI http://test in the usual way
any such prefix is mapped; i.e. a namespace context must be supplied.

The prefix in the XPath expression is irrelevant except for its mapping to the
URI. Only the namespace URI matters. This is how XPath works in XSLT. It is how
it works in Jaxen, XOM, and every other XPath implementation I have ever
encountered. It is this way by design, and there are good reasons for designing
iot this way. Xpath expressions do not always appear in XML documents. They do
not usually appear in the same document they are querying. And the fact that
unprefixed attributes are never in any namespace makes it really hard to use
unprefixed but qualified names in XPath expressions. 


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message