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

You can call the execQuery method from either an XmlObject or XmlCursor instance. Calling from XmlObject returns an XmlObject array. Calling from XmlCursor returns a new XmlCursor instance positioned at the root of a fragment containing copies of the XML queried against. Results of the query (if any) are sibling children of the fragment's root.
Field Summary
static final  String m_namespaceDeclaration     
Method from org.apache.xmlbeans.samples.xquery.ExecQuery Summary:
collectZips,   updateWorkPhone
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.xmlbeans.samples.xquery.ExecQuery Detail:
 public boolean collectZips(XmlObject empDoc) 
    Uses XQuery to retrieve work elements from the incoming XML, adding the elements as children to a element. This method demonstrates the following characteristics of the execQuery method: - it supports XQuery. - execQuery called from an XmlObject returns an array of XmlObject instances. These are bound to copies of the received XML.
 public boolean updateWorkPhone(XmlObject empDoc) 
    Uses XQuery to retrieve work elements from the incoming XML, then changes the number in the results. This method demonstrates the following characteristics of the execQuery method: - it supports XQuery. - the XML it returns is a copy of the XML queried against; contrast this with the selectPath method, which returns a portion of the original document. Changes to returned XML do not impact the XML queried against. - execQuery called from an XmlCursor returns a cursor positioned at the STARTDOC token of a new XML fragment. Contrast this with the XmlCursor.selectPath method, which stores results as "selections" in the cursor used to execute the query.