Moddy Te'eni wrote:
I'm trying to evaluate XPath expression on an input that looks like:
<Document xmlns="myNamespace/whatever"> ....
When I simply use "/Document", it doesn't work.
In order to overcome this problem, I wrote my own PrefixResolver, which
always returns "myNamespace/whatever", and then I can use the xpath
"/aaa:Document", but I still can't use the simpler form. The PrefixResolver
is never called for an empty prefix.
This could be how it should work according to w3c. I'm not sure about it.
Yes, this is explicit in the XPath recommendation:
http://www.w3.org/TR/xpath#node-tests
"A QName in the node test is expanded into an expanded-name using the
namespace declarations from the expression context. This is the same way
expansion is done for element type names in start and end-tags except
that the default namespace declared with xmlns is not used: if the QName
does not have a prefix, then the namespace URI is null (this is the same
way attribute names are expanded). It is an error if the QName has a
prefix for which there is no namespace declaration in the expression
context."
However, if it is not - how can I tell Xalan what is the namespace of the
empty prefix?
You can't. QNames without prefixes are always interpreted as having a
null namespace URI.
Dave