473,320 Members | 2,000 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

XPath filters equivalence

Hi,

Is [p1][p2][p3] the same as [p1 AND p2 and p3] in XPath?

Also if I have a predicate that starts with "/" or "//", does it
matter where in the XPath expression it is?

For example, are these equal:

/a[/a/b]/c/d
/a/c[/a/b]/d
/a/c/d[/a/b]

or these three:

/a[//a/b]/c/d
/a/c/[//a/b]/d
/a/c/d[//a/b]

Thanks in advance,
Al

Oct 6 '07 #1
4 2081
Altu wrote:
Is [p1][p2][p3] the same as [p1 AND p2 and p3] in XPath?
Depends on the predicate. If p2 or p3 tests position() or last(), _NO_
-- the latter form would test position in the original set, while the
former would test position in the set that has gotten past the
preceeding filter(s).
Also if I have a predicate that starts with "/" or "//", does it
matter where in the XPath expression it is?
/a[/a/b]/c/d
/a/c[/a/b]/d
/a/c/d[/a/b]
In these examples: no, since an absolute XPath by definition ignores its
context and since if it fails in any of these the result is that we find
no nodes. (Though for performance reasons in typical processors, you
will probably want to test it earlier rather than later).

In more complicated XPaths, maybe.
--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Oct 6 '07 #2
Hi Joe,
Depends on the predicate. If p2 or p3 tests position() or last(), _NO_
-- the latter form would test position in the original set, while the
former would test position in the set that has gotten past the
preceeding filter(s).
p1, p2, and p3 are simple paths that only have ., /, //, and * like

./a/b//c/d//*

or

//a/b//c//*
In these examples: no, since an absolute XPath by definition ignores its
context and since if it fails in any of these the result is that we find
no nodes. (Though for performance reasons in typical processors, you
will probably want to test it earlier rather than later).
In more complicated XPaths, maybe.
Other than performance difference, if my predicates are also simple
predicates like the case above, so I think they all return the same
result, is this correct?

Regards,
Al

Oct 6 '07 #3
Altu wrote:
Hi Joe,
>Depends on the predicate. If p2 or p3 tests position() or last(), _NO_
-- the latter form would test position in the original set, while the
former would test position in the set that has gotten past the
preceeding filter(s).

p1, p2, and p3 are simple paths that only have ., /, //, and * like

./a/b//c/d//*

or

//a/b//c//*
>In these examples: no, since an absolute XPath by definition ignores its
context and since if it fails in any of these the result is that we find
no nodes. (Though for performance reasons in typical processors, you
will probably want to test it earlier rather than later).
In more complicated XPaths, maybe.

Other than performance difference, if my predicates are also simple
predicates like the case above, so I think they all return the same
result, is this correct?
At this stage, why not download a copy of XPathTester and try it for
yourself?

///Peter
Oct 6 '07 #4
Hi again,

I just had a look at XPathTester. Looks like it is not
capable of finding out if two different queries are equivalent
or not, no matter what XML file they operate on.

-Al

On Oct 7, 5:00 am, Peter Flynn <peter.n...@m.silmaril.iewrote:
Altu wrote:
Hi Joe,
Depends on the predicate. If p2 or p3 tests position() or last(), _NO_
-- the latter form would test position in the original set, while the
former would test position in the set that has gotten past the
preceeding filter(s).
p1, p2, and p3 are simple paths that only have ., /, //, and * like
./a/b//c/d//*
or
//a/b//c//*
In these examples: no, since an absolute XPath by definition ignores its
context and since if it fails in any of these the result is that we find
no nodes. (Though for performance reasons in typical processors, you
will probably want to test it earlier rather than later).
In more complicated XPaths, maybe.
Other than performance difference, if my predicates are also simple
predicates like the case above, so I think they all return the same
result, is this correct?

At this stage, why not download a copy of XPathTester and try it for
yourself?

///Peter

Oct 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Sebastian Petzelberger | last post by:
Hi group, please give me an example of a xpath with regex or better a link with examples. Thanks in advance, Sebastian
8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
6
by: Scott Simpson | last post by:
What is a good tool for running XPath queries on Linux? I have the O'Reilly XPath book and I'm using XPath Visualizer on Windows and that seems to work fine, but I'm looking for something on Linux....
0
by: anthony.raj | last post by:
Hi, I have an XML Datasource in the following format - <?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?> <table> <event > <field name="user" value="anthony"/> <field name="date"...
18
by: jacksu | last post by:
I have a simple program to run xpath with xerces 1_2_7 XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); XPathExpression xp = xPath.compile(strXpr);...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
3
by: jmagaram | last post by:
I have a DataSet I want to work with as Xml using XmlDataDocument. I can't figure out how to query the resultant Xml using XPath. From the following XML below, what XPath query will return the list...
5
by: jorgedelgadolopez | last post by:
Hi all, I am using the xpathnavigator evaluate function on .net (xpath 1 right?). Now I need to expand the code to do multiple contains, compare dates (such as 'before', 'between' and 'after'),...
5
by: Altu | last post by:
Hi all, What does something like mean in an XPath query like /c/d ? If I am not wrong, /c/d means return all d elements that their parent is c and their grand parent is the root element and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.