Package org.htmlunit.html.xpath
Class XPathAdapter
- java.lang.Object
-
- org.htmlunit.html.xpath.XPathAdapter
-
class XPathAdapter extends java.lang.Object
XPath adapter implementation for HtmlUnit.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
XPathAdapter.STATE
-
Field Summary
Fields Modifier and Type Field Description private org.htmlunit.xpath.compiler.FunctionTable
funcTable_
private org.htmlunit.xpath.Expression
mainExp_
-
Constructor Summary
Constructors Constructor Description XPathAdapter(java.lang.String exprString, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver, javax.xml.transform.ErrorListener errorListener, boolean caseSensitive)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (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
initFunctionTable()
Initiates the function table.private static java.lang.String
preProcessXPath(java.lang.String xpath, boolean caseSensitive)
Pre-processes the specified case-insensitive XPath expression before passing it to the engine.
-
-
-
Constructor Detail
-
XPathAdapter
XPathAdapter(java.lang.String exprString, org.htmlunit.xpath.xml.utils.PrefixResolver prefixResolver, javax.xml.transform.ErrorListener errorListener, boolean caseSensitive) throws javax.xml.transform.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:
javax.xml.transform.TransformerException
- if a syntax or other error occurs
-
-
Method Detail
-
initFunctionTable
private void initFunctionTable()
Initiates the function table.
-
preProcessXPath
private static java.lang.String preProcessXPath(java.lang.String xpath, boolean caseSensitive)
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 javax.xml.transform.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:
javax.xml.transform.TransformerException
- if the error condition is severe enough to halt processing
-
-