[Phoenix] createNSResolver() related problems
Andreas Wuest
awuest at student.ethz.ch
Fri Sep 22 21:25:10 CEST 2006
Hi
There is a problem related to how namespace resolvers created by
createNSResolver work. Consider the following example:
<f:foo xmlns:f="foo.org">
<b:bar xmlns:b="bar.org"/>
</f:foo>
An XPath query "f:foo/b:bar" will not work if DOM level 3 method
createNSResolver() is used on the documentElement because
createNSResolver() creates a resolver containing all namespaces/prefixes
in the scope of the passed node. I.e., prefix "b" will be unknown,
because it is not in the scope of element <f:foo/>, and the query will fail.
I don't see a solution to this problem except demanding that all
prefixes used in the document are declared on the root node (and then
use this root node with createNSResolver()).
A different approach would be to walk the complete document, gathering
all prefixes and associated namespaces and thereby creating a custom
resolver. Of course, this approach fails as soon as we have a document like
<f:foo xmlns:f="foo.org">
<f:bar xmlns:f="bar.org"/>
</f:foo>
--
Kind regards,
Andi
More information about the Phoenix
mailing list