First, I really like the new setNamespaceURIs feature in CVS. It makes
xpath useful again. But, it is still a pain to have to create an
xpath, set the mapping, and then execute the xpath, instead of just
calling selectNodes, etc., directly on the context node.

What I have done to get around this is create my own DocumentFactory
which overrides createXPath to always bind the "my" prefix to the
namespace URI of the context node. Then I just use "my:" for
everything, unless I need a node from a different namespace (which
for me is rare).

It would be nice if this kind of shortcut were built in. I don't have
very good suggestions, though:
 1) Reserve a special namespace like "my" or "self"
 2) Make unprefixed elements default to the namespace of the context
    node (but how would you specify the empty namespace?)
 3) Add some way of setting a default prefix/namespace mapping for a
    whole document tree at a time, aside from writing your own
    DocumentFactory? A setNamespaceURIs method on Node?

-- Chris

_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to