Home » xmlbeans-2.5.0-src » org.apache.xmlbeans.samples » xquery » [javadoc | source]
public class: SelectPath [javadoc | source]
This class demonstrates how to use the selectPath method to execute XPath expressions. Compare the code here with the code in the ExecQuery class. That class uses the execQuery method to execute XQuery expressions.

You can call the selectPath method from either an XmlObject or XmlCursor instance. Calling from XmlObject returns an XmlObject array. Calling from XmlCursor returns void, and you use methods of the cursor to navigate among returned "selections".
Field Summary
static final  String m_namespaceDeclaration     
Method from org.apache.xmlbeans.samples.xquery.SelectPath Summary:
collectNames,   updateWorkPhone
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.xmlbeans.samples.xquery.SelectPath Detail:
 public boolean collectNames(XmlObject empDoc) 
    Uses the XPath text() function to get values from elements in received XML, then collects those values as the value of a element created here.

    Demonstrates the following characteristics of the selectPath method:

    - It supports expressions that include XPath function calls. - selectPath called from an XmlCursor instance (instead of an XMLBeans type) places results (if any) into the cursor's selection set.

 public boolean updateWorkPhone(XmlObject empDoc) 
    Prints the XML bound to empDoc, uses XPath to retrieve elements containing work phone numbers, changes the numbers to another number, then prints the XML again to display the changes. This method demonstrates the following characteristics of the selectPath method: - it supports expressions that include predicates - the XML it returns is the XML queried against -- not a copy, as with results returned via execQuery methods and XQuery. Changes to this XML update the XML queried against. - selectPath called from an XMLBean type (instead of a cursor) returns an array of results (if any). These results can be cast to a matching type generated from schema.