xml-xmlbeans-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Waite <m...@akuma.org>
Subject Re: A New approach for XPath using Namespace
Date Wed, 23 Jun 2004 17:14:07 GMT

On Jun 23, 2004, at 10:58 AM, nn wrote:

> Sorry forgetting to add prefix in the XPath (that is actually what I 
> don't
> like. It is too redundent. I want to use simple XPath without prefix
> assuming default namespace is the targetNamespace of the xsd file of 
> the
> target document).
Yes, but XPath 1.0 specifically says that this isn't the case:

http://www.w3.org/TR/xpath#node-tests

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.

this changes in XPath 2.0 (http://www.w3.org/TR/xpath20/#node-tests); 
you can define what the deafult element/type namespace is as another 
element of the expression context:

A QName in a name test is expanded into an expanded-QName using the 
in-scope namespaces in the expression context. It is a static error 
[err:XP0008] if the QName has a prefix that does not correspond to any 
in-scope namespace. An unprefixed QName, when used as a name test on an 
axis whose principal node kind is element, has the namespace URI of the 
default element/type namespace in the expression context; otherwise, it 
has no namespace URI.

Of course, XPath 2.0 isn't finished yet :)

-David Waite
Mime
View raw message