[jdom-interest] newbie question
Attila Szegedi
szegedia at freemail.hu
Thu Dec 5 01:31:00 PST 2002
----- Original Message -----
From: "bob mcwhirter" <bob at werken.com>
To: "Laurent Bihanic" <laurent.bihanic at atosorigin.com>
Cc: <jdom-interest at jdom.org>
Sent: 2002. december 4. 18:27
Subject: Re: [jdom-interest] newbie question
>
> 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.
>
Actually, I have such a situation (altough it is admittedly a border case
but I still have to support it). Namely, the XML support in FreeMarker uses
JDOM and Jaxen. I keep a static cache of already compiled XPath objects,
keyed by the expression string. So, if one template has:
...
${doc.registerNamespace("x", "http://foo.com")}
...
<assign bookNodes = doc("//x:book")>
...
and the other for some reason has:
...
${doc.registerNamespace("x", "http://bar.com")}
...
<assign bookNodes = doc("//x:book")>
...
then both "//x:book" XPath expressions are mapped to the same instance of
XPath object (static cache, remember?), but depending on which template
they're invoked from, they'll have different namespace mappings. As I said,
a border case, but one I have to support since I can't be sure what are my
template authoring users up to :-)
Attila.
More information about the jdom-interest
mailing list