Re: [xml] QName in Node Tests
- From: Daniel Veillard <veillard redhat com>
- To: Brian Stafford <brian stafford office-logic com>
- Cc: libxml-list <xml gnome org>
- Subject: Re: [xml] QName in Node Tests
- Date: Tue, 1 Apr 2003 10:21:48 -0500
On Tue, Apr 01, 2003 at 04:01:34PM +0100, Brian Stafford wrote:
All,
I've had some unexpected results using the XPath support in libxml2. I'm
unclear about what is supposed to happen even after having pored over the
XPath 1.0 spec. Specifically, given a document fragment
<top>
<xyzzy/>
<xyzzy xmlns="http://xyzzy.org/"/>
</top>
the node test '//xyzzy' matches only the first of the xyzzy elements rather
than both as I expected.
That normal.
Having read section "2.3 Node Tests" of XPath 1.0 which states
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.
I take the statement "except that the default namespace declared with xmlns is
not used" to mean that both xyzzy elements in the example above should have
been matched although I am by no means clear that this is what is intended.
No the second element has an expanded name of
{http://xyzzy.org}xyzzy
the first one' is
{null}xyzzy
and the node test xyzzy looks for expanded name {null}xyzzy
This is an XPath and XSLT Frequently Asked Question.
Looking at the code in xpath.c, function xmlXPathNodeCollectAndTest() near
line 9122 there is the following code
which is fine,
Daniel
--
Daniel Veillard | Red Hat Network https://rhn.redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]