| java.lang.Object org.apache.xmlbeans.samples.xquery.SelectPath
SelectPath | public class SelectPath (Code) | | 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".
|
Method Summary | |
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.
Parameters: empDoc - The incoming XML. | 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. |
m_namespaceDeclaration | final static String m_namespaceDeclaration(Code) | | |
collectNames | public boolean collectNames(XmlObject empDoc)(Code) | | 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.
Parameters: empDoc - The incoming XML. true if the XPath expression returned results;otherwise, false . |
updateWorkPhone | public boolean updateWorkPhone(XmlObject empDoc)(Code) | | 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.
Parameters: empDoc - The incoming XML. true if the XPath expression returned results;otherwise, false . |
|
|