[jdom-interest] newbie question

Laurent Bihanic laurent.bihanic at atosorigin.com
Thu Dec 5 02:48:04 PST 2002


bob mcwhirter wrote:
> I can understand needing dynamically resolvable VariableContext, but you
> have namespace prefix->uri bindings that change between invocations?
> The NamespaceContext really should be considered (or at least I consider
> it) to be a static member of the XPath itself, and not really settable
> after-the-fact.

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.

> 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? As long as the 
VariableContext is not passed to 
NamespaceContext.translateNamespacePrefixToUri(), I'll be stuck without any 
way to pass any context data through XPath.

Laurent




More information about the jdom-interest mailing list