943,888 Members | Top Members by Rank

Ad:
Jul 13th, 2009
0

Predicates Usage

Expand Post »
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......
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
urs.karuna1218 is offline Offline
5 posts
since Jul 2009
Jul 14th, 2009
0

Re: Predicates Usage

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
Reputation Points: 16
Solved Threads: 21
Junior Poster
xml_looser is offline Offline
178 posts
since Apr 2009
Jul 14th, 2009
0

Re: Predicates Usage

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.
Reputation Points: 22
Solved Threads: 11
Junior Poster
fpmurphy is offline Offline
144 posts
since Oct 2008
Jul 14th, 2009
0

Re: Predicates Usage

Thanks for the clear explaination folks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
urs.karuna1218 is offline Offline
5 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in XML, XSLT and XPATH Forum Timeline: Please help
Next Thread in XML, XSLT and XPATH Forum Timeline: XML query





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC