Package org.htmlunit.html.xpath
Class XPathAdapter
java.lang.Object
org.htmlunit.html.xpath.XPathAdapter
XPath adapter implementation for HtmlUnit.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.htmlunit.xpath.compiler.FunctionTable
private final org.htmlunit.xpath.Expression
-
Constructor Summary
ConstructorsConstructorDescriptionXPathAdapter
(String exprString, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver, ErrorListener errorListener, boolean caseSensitive) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) org.htmlunit.xpath.objects.XObject
execute
(org.htmlunit.xpath.XPathContext xpathContext, int contextNode, org.htmlunit.xpath.xml.utils.PrefixResolver namespaceContext) Given an expression and a context, evaluate the XPath and return the result.private void
Initiates the function table.private static String
preProcessXPath
(String xpath, boolean caseSensitive) Pre-processes the specified case-insensitive XPath expression before passing it to the engine.
-
Field Details
-
mainExp_
private final org.htmlunit.xpath.Expression mainExp_ -
funcTable_
private org.htmlunit.xpath.compiler.FunctionTable funcTable_
-
-
Constructor Details
-
XPathAdapter
XPathAdapter(String exprString, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver, ErrorListener errorListener, boolean caseSensitive) throws TransformerException Constructor.- Parameters:
exprString
- the XPath expressionprefixResolver
- a prefix resolver to use to resolve prefixes to namespace URIserrorListener
- the error listener, ornull
if default should be usedcaseSensitive
- whether the attributes should be case-sensitive- Throws:
TransformerException
- if a syntax or other error occurs
-
-
Method Details
-
initFunctionTable
private void initFunctionTable()Initiates the function table. -
preProcessXPath
Pre-processes the specified case-insensitive XPath expression before passing it to the engine. The current implementation lower-cases the attribute name, and anything outside the brackets.- Parameters:
xpath
- the XPath expression to pre-processcaseSensitive
- whether or not the XPath expression should be case-sensitive- Returns:
- the processed XPath expression
-
execute
org.htmlunit.xpath.objects.XObject execute(org.htmlunit.xpath.XPathContext xpathContext, int contextNode, org.htmlunit.xpath.xml.utils.PrefixResolver namespaceContext) throws TransformerException Given an expression and a context, evaluate the XPath and return the result.- Parameters:
xpathContext
- the execution contextcontextNode
- the node that "." expressesnamespaceContext
- the context in which namespaces in the XPath are supposed to be expanded- Returns:
- the result of the XPath or null if callbacks are used
- Throws:
TransformerException
- if the error condition is severe enough to halt processing
-