[jdom-interest] newbie question

bob mcwhirter bob at werken.com
Thu Dec 5 05:14:39 PST 2002

> Here a trivial example to illustrate my use case:
> 1. The user enters an XPath expression such as ".//foo:bar"
> 2. The user selects a node on which apply the XPath, for example <a> and <b> 
> in the following document:
> <doc>
>    <a xmlns:foo="urn:abc:xyz">
>      <x>
>        <bar>bar 1</bar>
>      </x>
>    </a>
>    <b xmlns:foo="urn:xyz:abc">
>      <y>
>        <bar>bar 2</bar>
>      </y>
>    </b>
> </doc>
> I then need a context-dependant dynamic namaspace resolution as both <a> and 
> <b> declare the same prefix for different namespaces. Hence the 
> NamespaceContext implementation that needs to access the context object.

That seems like a massive mis-use of namespaces and prefix bindings.

The prefixes in an XPath are in no way related to the prefixes used in 
a document.  The theory is that a user should be able to write:


and denote that "goober" maps to "urn:xyz:abc" and still select the
correct nodes from the document, regardless of the doc's own prefix->uri

It really seems that your use-case is more of an ignore-namespaces functionality,
where you really only check the local-name of an element.

Would an ignoreNamespaces(boolean) satisfy your needs better?

> > So, in this case, you pass your own magical VariableContext into
> > the evaluation.  You can consider the VariableContext to be your
> > applicate object.  You just have to implement the VariableContext
> > interface on whatever object you care to pass around.
> How can this helps me solving the NamespaceContext problem? 

You're right, it wouldn't solve your problem.  


More information about the jdom-interest mailing list