Jeff Greif wrote:
No, if you omit a prefix from an element name in an xpath, you tell the xpath processor the element you want is in no namespace.
OK .. granted.
As far as I can tell, the prefix resolver is only called on the xpath (not on nodes of the document). So you might provide a prefix resolver extending PrefixResolverDefault which knows the mappings of a certain set of prefixes which you use in your xpath, and lets the default resolver's method handle all others.
With a quick test, the PrefixResolverDefault returns the proper namespace via its getNamespaceForPrefix() method ... so does the XPathNSResolverImpl via the same method and the lookupNamespaceURI() method. So the resolver is fine.
What the problem is I do not know in advance the prefix that may be used by a given namespace.
All I know is that there will be two namespaces used, the SOAP namespace and the MM7 namespace.
Also, the same namespace could be used in a single XML document with different prefixes. Argh!
So how do you specify an expression if you do not know in advance the namespace prefixes used in the document?
Wouldn't it have been better if instead of the prefix as part of the expression, you instead use the namspace URI itslef is used?
e.g.:
//http:mynamespace.org:ElementA/http:yournamespace.org:ElementB/
... so you do not have to worry about prefixes in your xpath expression.
Oh well.
