On Fri, 21 Sep 2001, James Strachan wrote:

> You can bind the empty prefix to a namespace URI. Its often called the
> 'default namespace'.
>
> e.g.
>
> <foo xmlns="someURI">
>     <bar/>
> </foo>
>
> In the above document the XPath expression /foo/bar will not work unless you
> explicitly setup a NamespaceContext to set the default namespace URI to be
> "someURI". If you map empty prefix, "", to "someURI" in your
> NamespaceContext then /foo/bar will work.

That would have been convenient if it were possible, but there are two
problems:

* xpath explicitly disallows it, in section 2.3:
"A QName in the node test is expanded into an expanded-name using the
namespace declarations from the expression context. This is the same way
expansion is done for element type names in start and end-tags except
that the default namespace declared with xmlns is not used: if the
QName does not have a prefix, then the namespace URI is null (this is the
same way attribute names are expanded). It is an error if the QName has a
prefix for which there is no namespace declaration in the expression
context."

* a practical one: functions and variables are also qualified names; if
you were to rebind the empty prefix to some namespace, then you wouldn't
be able to call any of the built-in xpath functions, since they have no
namespace URI. Jaxen simply won't be able to find the functions or
variables.

Greetings,
  Erwin



_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to