Re: [xml] Possible Problem|Bug in the XPath Subsystem



On Tue, Mar 18, 2003 at 01:31:14PM +0100, Christian Glahn wrote:
Hello,

While preparing XML::LibXML for a release I added some tests for XPath 
statements. I stumbled over some strange issues with XPath statements.
It looks pretty much like a inconsisty in the XPath engine to me.

I give some example documents. All statements are executed on the
document node or the document element node.

     <C:A xmlns:C="D"><C:A><C:B/></C:A><C:A><C:B/></C:A></C:A>

delivers with the following XPath statement the expected results:

     descendant-or-self::node()/C:A

all three nodes are returned as expected if run on the root element.

This is allright if the following documents and statements won't fail, 
but they do. :(

Case a) with default namespaces

    <A xmlns="D"><A><B/></A><A><B/></A></A>

and the stantement 

   descendant-or-self::node()/A

doesn't return anything

  That's normal, compliance with the spec ! "A" matches only
node of name A in no namespace, check the spec !

Case b) no namespace but a 'prefix'

    <C:A><C:A><C:B/></C:A><C:A><C:B/></C:A></C:A>

and the statement 

    descendant-or-self::node()/C:A

returns no nodes

  XPath requires the document to be compliant with the namespace REC
and that's not the case, 

funny enough the statement 

    descendant-or-self::*[local-name()='A']

returns three nodes on the same document, although there is no localname 'A'
in the first place. and the statement

    descendant-or-self::*[local-name()='C:A']

again returns nothing, although I expect no namespace prefix present.

Because of this inconsisty I am a bit confused ... is it just me or is it a
bug?

  You're operating outside of the scope of the specification.
Libxml2 will emit a warning on your document, it's well formed w.r.t. 
the XML REC 1.0 but not compliant to the Namespace in XML REC.

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]