RE: [xsl] Namespace wildcards

> In fact, I think your suggestion that people will use *:mumble because of
> the difficulty of defining namespace declarations in the XPath context
> confirms these fears. It makes life too easy for people who can't be
> bothered to declare their namespaces properly, and their queries will work
> perfectly well until the day that someone creates a document that mixes in
> names from another namespace.

Actually, it was based on the XPath 1.0 model:

+ if the QName does not have a prefix, then the namespace URI is null (this is
+ the same way attribute names are expanded)

whereas I see now that Xpath 2.0 says

+ Default namespace for element names. This is a namespace URI. This namespace
+ is used for any unprefixed QName appearing in a position where an element name
+ is expected.

This is great and is a huge improvement over the 1.0 spec. A teeny bit of
a backward compatibility hit but well worth it and not likely to affect anyone.
Guess I should have re-read the 2.0 spec; don't remember it being there last
time I looked and it's not in the "Backwards Compatibility with XPath 1.0"
but maybe it's not dramatic enough to be put in there. Or maybe this was just
a clarification? Though I don't see how the XPath 1.0 spec could be interpreted
to mean what the 2.0 spec says. Anyway, sorry, I'll retract about always using
*:mumble.

Still don't know if a *:mumble syntax is any more dangerous than a
mumble:* syntax and if you're going to have the latter seems you might
as well adopt a foolish consistency and allow the former. Give 2.0's
reasonable default namespace behavior I doubt if novices will be sorely
tempted to use the *:mumble syntax. A couple of questions along these lines:
The spec says:

+ A node test * is true for any node of the principal node type.  For example,
+ child::* will select all element children of the context node, and attribute::*
+ will select all attributes of the context node

I assume that's in the default element namespace only?

Also, is *:* allowed? The spec doesn't preclude this but it also is explicit
about allowing NCName:* and *:NCName so this might suggest that it's not?
Seems like it may as well be allowed to me.

> In fact, I think your suggestion that people will use *:mumble because of
> the difficulty of defining namespace declarations in the XPath context
> confirms these fears. It makes life too easy for people who can't be
> bothered to declare their namespaces properly, and their queries will work
> perfectly well until the day that someone creates a document that mixes in
> names from another namespace.

I think that the difference is that a procedural language is more likely
to be doing things like looking at all nodes and then determining the
namespace of each node and then doing something on the basis of that
namespace. Don't know XSLT well enough to know if you can do this there
but it strikes me as a procedural thing.

> Sorry, but I can't see anything in this argument that's specific to XSLT:
> it's equally true for any environment in which XPath is used. Is your
> argument based on the fact that some XPath host environments make it
> difficult to declare namespace prefixes in the XPath context? In that case,
> I think those environments should be fixed.

I think a procedural language would tend to need a lot less from XPath
than a non-procedural one like XSLT. Anyway, my argument was based on
my mistaken belief that XPath didn't allow the host environment to
have a default namespace.

Thanks,

Alex Kodat
Sirius Software
Cambridge, MA

Received on Tuesday, 5 February 2002 12:07:46 UTC