473,320 Members | 1,979 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.

A question about XPath filters (predicates)

Hi all,

What does something like [/a/b] mean in an XPath query like /c/d[/a/
b] ?

If I am not wrong, /c/d[./a/b] means return all d elements that their
parent is c and their grand parent is the root element and have a
child that is a and their a child has a child b. But I don't know when
we don't use an expression that starts with ./ or .// in a predicate
and instead use an epxression that starts with / or // what it would
mean.

Does /c/d[/a], for example, mean return all d elements that have a
parent (c with a parent root) only if the root has a child a?

Thanks in advance.

Oct 6 '07 #1
5 2683
Altu schrieb:
Does /c/d[/a], for example, mean return all d elements that have a
parent (c with a parent root) only if the root has a child a?
Yes, but the root is either c or a. So the XPath expression does not
select anything.

--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
Oct 6 '07 #2
Johannes Koch schrieb:
Altu schrieb:
>Does /c/d[/a], for example, mean return all d elements that have a
parent (c with a parent root) only if the root has a child a?

Yes, but the root is either c or a.
I mean the root _element_.
So the XPath expression does not
select anything.
--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)
Oct 6 '07 #3
Hi Johannes,

Thanks for the reply. Also what is the meaning of multiple consequtive
filters like

a[p1][p2][p2]

Does it mean a elements that satisfy p1 AND p2 and p3?

-Al

On Oct 6, 7:04 pm, Johannes Koch <k...@w3development.dewrote:
Johannes Koch schrieb:
Altu schrieb:
Does /c/d[/a], for example, mean return all d elements that have a
parent (c with a parent root) only if the root has a child a?
Yes, but the root is either c or a.

I mean the root _element_.
So the XPath expression does not
select anything.

--
Johannes Koch
Spem in alium nunquam habui praeter in te, Deus Israel.
(Thomas Tallis, 40-part motet)

Oct 6 '07 #4
Altu wrote:
Thanks for the reply. Also what is the meaning of multiple consequtive
filters like
a[p1][p2][p2]

Does it mean a elements that satisfy p1 AND p2 and p3?
Exactly. By the way, the proper term is "predicates", not filters.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Oct 6 '07 #5
In article <47***********************@authen.yellow.readfreen ews.net>,
Johannes Koch <ko**@w3development.dewrote:
>>Does /c/d[/a], for example, mean return all d elements that have a
parent (c with a parent root) only if the root has a child a?
>Yes, but the root is either c or a.
The root node has exactly one element child, which is the root element.
You can only have /c/d if the root element is c, and [/a] will only
be true if the root element is a, so it will never succeed.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Oct 6 '07 #6

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

Similar topics

2
by: ahogue at theory dot lcs dot mit dot edu | last post by:
Hello - Is there any way to match complex subtree patterns with XPath? The functions I see all seem to match along a single path from root to leaf. I would like to match full subtrees. For...
2
by: Anna | last post by:
Hi all. I am using Jaxen to evaluate XPath expressions in Java. I encountered problems when comparing results returned by jaxen with results returned by other XPath implementation - I was using...
4
by: gfrommer | last post by:
Hello everyone, I've been reading through a bunch of XPath tutorials and am confused by a couple items. First, is it possible to have multiple predicates in my XPath statement. For example, the...
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...
4
by: Altu | last post by:
Hi, Is the same as 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/c/d
2
by: Weston | last post by:
Poking around with XPath using SimpleXML, it looks like there are at least a few reasonably common XPath operators and predicates that aren't supported. I'd like to check my observations against...
2
by: arunairs | last post by:
Hi, Is there a way of validating and XPath? In this case , I am accepting an XPath from the user and I need to validate the XPath syntax. Is there a regular expression available that anyone can...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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

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.