On Monday, 10/25/2004 at 08:08 AST, "Rick Bullotta"
<[EMAIL PROTECTED]> wrote:
> Aren't default namespaces just EVIL? ;)
No, they're just syntactic sugar so you don't have to specifiy the
"primary" namespace for your document everywhere you use it.
> I always felt that this was a near-fatal flaw in the binding between XML
and
> Xpath/XSLT...as it creates the need for a "programmer" to consciously
"add"
> something to a DOM, parser or other component to enable Xpathing anything
> with a default namespace somewhere in the path.
XPath is intended to operate on the semantic (namespaced) view of the
document, not on the syntax (prefix). From XPath's point of view, it
doesn't matter whether the namespace binding is default or explicit. This
isn't a matter of adding something to a document component, but of saying
what you mean in the XPath. Unfortunately:
> the context used for an Xpath expression in product "A" might not be the
> same as product "B".
That's definitely true. I've no objection to XPath processors being able to
accept namespace bindings as input, but I'm really ticked off that they
didn't provide a way to express those as part of the XPath for those
situations where you want the path to be portable.
The usual workaround is to interpret an XPath in the context of some
specific point in the document and the namespace bindings in effect at that
point. That works for those situations where the XPath appears in the
document... but it doesn't work particularly well for tools which may not
have such an obvious context.
I've grumbled about this to the XPath 2.0 group in the past. I don't know
whether anything's being done about it.
I believe they *are* doing something about being able to define the default
namespace for an XPath. But I worry that unless they address the
portability/self-containedness issue, that's going to be another "obtain it
from the environment in some unspecified way" item.
> But as well all know, there isn't an easy solution...other than not using
> default namespaces or providing a prefix mapping in the source document
for
> each default namespace URI.
Providing a prefix mapping *somewhere*. Context node, Xalan Prefix Resolver
object, a revalation from the programming deity of your choice (who's the
patron saint of unbound variables?)...
> Any other recommended "best practices"?
Until fixed, this really boils down to: XPaths require prefixes to
reference namespaced nodes. Make sure they're defined correctly somewhere
in the XPath engine's context -- the document containing the XPath, or the
(implementation-dependent) system environment.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]