Home Products Consulting About Us White Papers Careers Contact Us Tutorials
 

 Download Delve® SOA Fast-Prototyping Toolkit (Beta 1.0)

Tutorials - How To Use a Built-In Function in XPath
Page 2 of 2

Sometimes an XPath expression should evaluate to a value that doesn’t contain XML document member content at all, but rather the result of some computation based on member content. For instance, what if we want to determine how many children a particular parent has? This is a computed value, not contained anywhere in the source document. We can obtain it using the “count” function.

 

 

In this example, a filter, accessors, and the “count” function combine to produce the desired result.

In order to understand more complex XPath expressions, it can help to think of the expression as a “chain” in which each link is an accessor argument. The “ps” argument passes the target document along to the “count” function which in turn passes to the expression used as its single argument. The “parent” member name is used to extract the set of all “parent” elements from the target document, and the “fname” filter removes all of those for which fname is not “Jenny.”

This element is passed along to the next link in the chain, which obtain’s Jenny’s “children” element. The last accessor obtains all of Jenny’s child elements. The “count” function then determines how many “children” elements there are—letting us know how many children Jenny has.


 Download Delve® SOA Fast-Prototyping Toolkit (Beta 1.0)
Previous Step

Go Back To Previous Step

View Entire Code Sample

Read a Detailed Product Description

Read About Delve and XPath in Detail

Browse Product White Papers

 
Home Products Consulting About Us White Papers Careers Contact Us Tutorials