com.ibm.mashups.enabler.xml
Interface XPath


public XPath

Interface provides functions to select nodes by evaluating XPATH expression


Method Summary
 XMLNodeList evaluateXPath(String xpathExpr, XMLDocument doc, JSON namespaces)
           This interface returns a list of XMLNodes upon XPATH evaluation.
 Object evaluateEntry(String xpathExpr, XMLDocument doc, JSON namespaces)
           This interface returns a single Entry upon XPATH evaluation or null if the entry is not present.
 Boolean evaluateBoolean(String xpathExpr, XMLDocument doc, JSON namespaces)
           This interface returns a boolean upon XPATH evaluation.
 String evaluateString(String xpathExpr, XMLDocument doc, JSON namespaces)
           This interface returns a String upon XPATH evaluation.
 Number evaluateNumber(String xpathExpr, XMLDocument doc, JSON namespaces)
           This interface returns a Number upon XPATH evaluation.
 

Method Detail

evaluateXPath

XMLNodeList evaluateXPath(String xpathExpr,
                          XMLDocument doc,
                          JSON namespaces)
This interface returns a list of XMLNodes upon XPATH evaluation.

Parameters:
xpathExpr - the xpath expression (i.e. /atom:content). Must not be NULL.
doc - the XML document. Must not be NULL.
namespaces - the namespaces used as part of the xpath expression. The json must be of the format { "prefix": "URL", ... }; must not be NULL.
Example: { "atom" : "http://www.w3.org/2005/Atom", "app" : "http://www.w3.org/2007/app" };
Returns:
select nodes from XML document with xpath; may be null.

evaluateEntry

Object evaluateEntry(String xpathExpr,
                     XMLDocument doc,
                     JSON namespaces)
This interface returns a single Entry upon XPATH evaluation or null if the entry is not present.

Parameters:
xpathExpr - the xpath expression (i.e. /atom:content). Must not be NULL.
doc - the XML document. Must not be NULL.
namespaces - the namespaces used as part of the xpath expression. The json must be of the format { "prefix": "URL", ... }; must not be NULL.
Example: { "atom" : "http://www.w3.org/2005/Atom", "app" : "http://www.w3.org/2007/app" };
Returns:

evaluateBoolean

Boolean evaluateBoolean(String xpathExpr,
                        XMLDocument doc,
                        JSON namespaces)
This interface returns a boolean upon XPATH evaluation. Returns false if the result is not valid (e.g. node does not exist, etc.).

Parameters:
xpathExpr - the xpath expression (i.e. /atom:content). Must not be NULL.
doc - the XML document. Must not be NULL.
namespaces - the namespaces used as part of the xpath expression. The json must be of the format { "prefix": "URL", ... }; must not be NULL.
Example: { "atom" : "http://www.w3.org/2005/Atom", "app" : "http://www.w3.org/2007/app" };
Returns:

evaluateString

String evaluateString(String xpathExpr,
                      XMLDocument doc,
                      JSON namespaces)
This interface returns a String upon XPATH evaluation. Returns an empty String if the result is not valid (e.g. node does not exist, etc.). If you want to check for existence of an attribute/element use either evaluateBoolean (which returns false if the element is not present) or evaluateEntry (which returns null if the element is not present).

Parameters:
xpathExpr - the xpath expression (i.e. /atom:content). Must not be NULL.
doc - the XML document. Must not be NULL.
namespaces - the namespaces used as part of the xpath expression. The json must be of the format { "prefix": "URL", ... }; must not be NULL.
Example: { "atom" : "http://www.w3.org/2005/Atom", "app" : "http://www.w3.org/2007/app" };
Returns:

evaluateNumber

Number evaluateNumber(String xpathExpr,
                      XMLDocument doc,
                      JSON namespaces)
This interface returns a Number upon XPATH evaluation. Returns zero (0) if the result is not valid (e.g. node does not exist, etc.). If you want to check for existence of an attribute/element use either evaluateBoolean (which returns false if the element is not present) or evaluateEntry (which returns null if the element is not present).

Parameters:
xpathExpr - the xpath expression (i.e. /atom:content). Must not be NULL.
doc - the XML document. Must not be NULL.
namespaces - the namespaces used as part of the xpath expression. The json must be of the format { "prefix": "URL", ... }; must not be NULL.
Example: { "atom" : "http://www.w3.org/2005/Atom", "app" : "http://www.w3.org/2007/app" };
Returns:


Copyright IBM Corp. 2010 All Rights Reserved.