473,811 Members | 2,729 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2704
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...@w3develop ment.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************ ***********@aut hen.yellow.read freenews.net>,
Johannes Koch <ko**@w3develop ment.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
--
"Considerat ion 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
5059
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 example, given the XHTML: <html> <body>
2
2705
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 Saxon. Here is my example: <p> <span>text1</span> </p> <div>text2</div>
4
2163
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 following xpath statement: "//AAA/BBB/c" should only return the last <c> node containing the 6, correct? Also consider the statement "//AAA/BBB" returns the first two <BBB> items, correct? the and's and or's in the predicates are all right yes?
18
7740
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); System.out.println(xp.evaluate(new InputSource(new FileInputStream("a.xml"))));
9
2157
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 should work. Also the second nav.OuterXml appears to also be wrong to me. Can someone explain to me why this does not work? (This is an example from a program we have where xpath can be entered in two parts so we have to be able
4
2102
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
2763
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 other people's experience, and find out if I'm missing something. Here's what it looks like to me in PHP 5.2.0: * the count() predicate seems to fail quietly (no error or warning, you just receive a false value from the xpath method rather than...
2
4723
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 direct me to, to validate a XPath? thanks, Arun
0
9734
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10652
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10408
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10137
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9211
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7673
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.