Predicates Usage

Please support our XML, XSLT and XPATH advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2009
Posts: 5
Reputation: urs.karuna1218 is an unknown quantity at this point 
Solved Threads: 0
urs.karuna1218 urs.karuna1218 is offline Offline
Newbie Poster

Predicates Usage

 
0
  #1
Jul 13th, 2009
Hi Folks,
Can anyone explain me whether we can use multiple predicates in the path expression.
In the below path, // indicates searching for the node in XML document irrespective of its position, but I didn't understand why 'starts-with' function is placed in [] brackets. Even though it's working fine, can anyone explain how it works?

Here is the path for your reference.
<code>
path="//*[starts-with(name(), 'FSA')][position()=//count/text()]/@SCIObjectID"
</code>

Thanks in Advance......
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 44
Reputation: xml_looser is an unknown quantity at this point 
Solved Threads: 2
xml_looser xml_looser is offline Offline
Light Poster

Re: Predicates Usage

 
0
  #2
Jul 14th, 2009
path="//*[starts-with(name(), 'FSA')][position()=//count/text()]/@SCIObjectID"


[] a Predicates content a false true


starts-with(name(), 'FSA') when the current tagname
a FSA****

* are any sign of the alpabeth
then second predicate
compare positionnummer with current Tagnode child count value

then alle predicate are true the parser found the arttirbut

@SCIObjectID
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 95
Reputation: fpmurphy is an unknown quantity at this point 
Solved Threads: 5
fpmurphy fpmurphy is offline Offline
Junior Poster in Training

Re: Predicates Usage

 
0
  #3
Jul 14th, 2009
Yes, multiple precidates are permitted in a step. In your example you have two adjacant predicates.

From XPath 2.0 3.2.1
A step is a part of a path expression that generates a sequence of items and then filters the sequence by zero or more predicates. The value of the step consists of those items that satisfy the predicates, working from left to right. A step may be either an axis step or a filter expression.

[starts-with(name(), 'FSA')] is a predicate as indicated by the square brackets.

From XPath 2.0 3.2.2
A predicate consists of an expression, called a predicate expression, enclosed in square brackets. A predicate serves to filter a sequence, retaining some items and discarding others. In the case of multiple adjacent predicates, the predicates are applied from left to right, and the result of applying each predicate serves as the input sequence for the following predicate.
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 5
Reputation: urs.karuna1218 is an unknown quantity at this point 
Solved Threads: 0
urs.karuna1218 urs.karuna1218 is offline Offline
Newbie Poster

Re: Predicates Usage

 
0
  #4
Jul 14th, 2009
Thanks for the clear explaination folks
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the XML, XSLT and XPATH Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC