Re: [xml] XPath / LibXML question
- From: "Buchcik, Kasimier" <k buchcik 4commerce de>
- To: "Buchcik, Kasimier" <k buchcik 4commerce de>
- Cc: xml gnome org
- Subject: Re: [xml] XPath / LibXML question
- Date: Mon, 19 Jun 2006 13:24:13 +0200
Hi,
I optimized the predicate evaluation for this case; but only
when using the short-hand form "[n]".
The following will now stop at the first "item" element which
satisfies [ attr1 = '1']:
"/base/group/descendant::instance[ att2='2' and
parent::instances/parent::item[ att1='1']][1]"
Use xpath.c revision 1.136.
Regards,
Kasimier
-----Original Message-----
From: xml-bounces gnome org [mailto:xml-bounces gnome org] On
Behalf Of Buchcik, Kasimier
Sent: Thursday, June 01, 2006 7:57 PM
To: Buchcik, Kasimier
Cc: xml gnome org
Subject: RE: [xml] XPath / LibXML question
Hi,
-----Original Message-----
From: xml-bounces gnome org [mailto:xml-bounces gnome org] On
Behalf Of Buchcik, Kasimier
-----Original Message-----
From: Alan_McCarthy scee net [mailto:Alan_McCarthy scee net]
Sent: Thursday, June 01, 2006 5:18 PM
To: Buchcik, Kasimier
Cc: Aron Stansvik; Buchcik, Kasimier; xml gnome org
Subject: RE: [xml] XPath / LibXML question
Well, that certainly returns just the one result correctly...
I take it from your comments about it not being optimized
that it will
still find all results before returning the first, rather
than just
terminating at the first match?
Although it will return just one node, it will still try to
apply the
predicate "[ att2='2' and
parent::instances/parent::item[ att1='1']]"
on all "instance" elements it finds in the document. So
actually it will
run even slower than your original expression. I'll try to optimize
this.
But the expression I proposed (even if optimized) has the
drawback that
it won't be as efficient as a plain chain of node-tests in the child
axis,
if you *don't* know if the document will be of the expected
structure.
Hmm, don't know if I expressed this understandable enough; I
think this
will become clearer if we assume that the given document has
a document
element with the name "foo"; here my expression will still
search the
whole tree for "instance" elements, while your expression would stop
already at the document element. So it all depends on how
much you can
assume about the queried tree.
[...]
Apparently I haven't thought the issue to the end. Of course there's
also a way to restrict this to be an element inside /base/group:
"/base/group/descendant::instance[ att2='2' and
parent::instances/parent::item[ att1='1']][1]"
Regards,
Kasimier
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]