Connecting Tech Pros Worldwide Help | Site Map

how to find elements that don't have ancestor

  #1  
Old October 10th, 2008, 07:25 PM
kishjeff
Guest
 
Posts: n/a
Hi.

Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?

I'm sort of wrestling with it and am hoping someone can tell me if it
is possible.

I know it is possible to find all elements that ARE descendents of
'querybox' that have a given attribute and are of a certain type.

Jeff
  #2  
Old October 10th, 2008, 07:35 PM
kishjeff
Guest
 
Posts: n/a

re: how to find elements that don't have ancestor


On Oct 10, 2:17*pm, kishjeff <jk...@us.ibm.comwrote:
Quote:
Hi.
>
Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?
>
I'm sort of wrestling with it and am hoping someone can tell me if it
is possible.
>
I know it is possible to find all elements that ARE descendents of
'querybox' that have a given attribute and are of a certain type.
>
Jeff
oh geez, I'm trying out xpath. sorry.. I forgot to mention that
insignificant item.
  #3  
Old October 10th, 2008, 09:05 PM
Peyo
Guest
 
Posts: n/a

re: how to find elements that don't have ancestor


kishjeff a écrit :
Quote:
Quote:
>Can someone tell me how to find all the elements of type 'table' which
>have an attribute named 'source' and are not descendents of
>'querybox' ?
Quote:
oh geez, I'm trying out xpath. sorry.. I forgot to mention that
insignificant item.
Why not :
//table[@source and (count(ancestor::querybox) = 0)]

Cheers,

p.


  #4  
Old October 11th, 2008, 12:55 AM
kishjeff
Guest
 
Posts: n/a

re: how to find elements that don't have ancestor


On Oct 10, 4:02*pm, Peyo <o...@est.cawrote:
Quote:
kishjeff a écrit :
>
Quote:
Quote:
Can someone tell me how to find all the elements of type 'table' which
have an attribute named 'source' and are not descendents of
'querybox' ?
oh geez, I'm trying out xpath. sorry.. I forgot to mention that
insignificant item.
>
Why not :
//table[@source and (count(ancestor::querybox) = 0)]
>
Cheers,
>
p.
thanks so much. that works just fine evidently. is there a way of
doing it without count, say with some sort of "not
decendent::querybox" sort of thing?

regards in any case
Jeff
  #5  
Old October 11th, 2008, 07:55 AM
Peyo
Guest
 
Posts: n/a

re: how to find elements that don't have ancestor


kishjeff a écrit :
Quote:
thanks so much. that works just fine evidently.
You did most of the work ;-)

< is there a way of
Quote:
doing it without count, say with some sort of "not
decendent::querybox" sort of thing?
Just try not(descendant::querybox)

not() is a *function*, hence the parentheses.

XPath 2.0 also introduces some other functions like exists().

Be aware that not(descendant::querybox) it is not what you have asked :-)

Cheers,

p.b.
  #6  
Old October 11th, 2008, 02:35 PM
Peter Flynn
Guest
 
Posts: n/a

re: how to find elements that don't have ancestor


kishjeff wrote:
Quote:
On Oct 10, 4:02 pm, Peyo <o...@est.cawrote:
Quote:
>kishjeff a écrit :
>>
Quote:
>>>Can someone tell me how to find all the elements of type 'table' which
>>>have an attribute named 'source' and are not descendents of
>>>'querybox' ?
>>oh geez, I'm trying out xpath. sorry.. I forgot to mention that
>>insignificant item.
>Why not :
>//table[@source and (count(ancestor::querybox) = 0)]
>>
>Cheers,
>>
>p.
>
thanks so much. that works just fine evidently. is there a way of
doing it without count, say with some sort of "not
decendent::querybox" sort of thing?
>
regards in any case
Jeff
//table[@source and not(ancestor::querybox)]

///Peter
  #7  
Old October 12th, 2008, 02:55 PM
Jeff Kish
Guest
 
Posts: n/a

re: how to find elements that don't have ancestor


On Sat, 11 Oct 2008 14:31:08 +0100, Peter Flynn
<peter.nosp@m.silmaril.iewrote:
Quote:
>kishjeff wrote:
Quote:
>On Oct 10, 4:02 pm, Peyo <o...@est.cawrote:
Quote:
>>kishjeff a écrit :
>>>
>>>>Can someone tell me how to find all the elements of type 'table' which
>>>>have an attribute named 'source' and are not descendents of
>>>>'querybox' ?
>>>oh geez, I'm trying out xpath. sorry.. I forgot to mention that
>>>insignificant item.
>>Why not :
>>//table[@source and (count(ancestor::querybox) = 0)]
>>>
>>Cheers,
>>>
>>p.
>>
>thanks so much. that works just fine evidently. is there a way of
>doing it without count, say with some sort of "not
>decendent::querybox" sort of thing?
>>
>regards in any case
>Jeff
>
>//table[@source and not(ancestor::querybox)]
>
>///Peter
ah its so easy... thanks.
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT Tips you don't learn at w3schools jkmyoung insights 2 December 8th, 2008 04:26 PM
How to center vertically ? FL answers 27 July 20th, 2005 10:38 PM
How often is my recursive template called ?? Rolf Kemper answers 7 July 20th, 2005 08:49 AM
XPath / XSLT to extract 'overloaded' attribute Iain answers 9 July 20th, 2005 07:35 AM