/** * Evaluate a compiled XPath expression relative to a node such as a node * returned by a previous XPath expression. * An XPath expression can return a Node or subinterface such as * Element or Text, a NodeList, or a Boolean, Number, or String value. * @param xpathExpression an XPath expression compiled previously * @param context the node for evaluating the expression * @param as the type of the value * @return the value produced by the XPath expression */ public <T> T evaluateXPath(XPathExpression xpathExpression, Node context, Class<T> as) throws XPathExpressionException { checkContext(context); return castAs( xpathExpression.evaluate(context, returnXPathConstant(as)), as ); } protected void checkContext(Node context) {
/** * Evaluate a compiled XPath expression relative to a node such as a node * returned by a previous XPath expression. * An XPath expression can return a Node or subinterface such as * Element or Text, a NodeList, or a Boolean, Number, or String value. * @param xpathExpression an XPath expression compiled previously * @param context the node for evaluating the expression * @param as the type expected to be matched by the xpath * @param <T> the type to return * @return the value produced by the XPath expression * @throws XPathExpressionException if xpathExpression cannot be evaluated */ public <T> T evaluateXPath(XPathExpression xpathExpression, Node context, Class<T> as) throws XPathExpressionException { checkContext(context); return castAs( xpathExpression.evaluate(context, returnXPathConstant(as)), as ); } protected void checkContext(Node context) {
/** * Evaluate a string XPath expression relative to a node such as a node * returned by a previous XPath expression. * An XPath expression can return a Node or subinterface such as * Element or Text, a NodeList, or a Boolean, Number, or String value. * @param xpathExpression the XPath expression as a string * @param context the node for evaluating the expression * @param as the type of the value * @return the value produced by the XPath expression */ public <T> T evaluateXPath(String xpathExpression, Node context, Class<T> as) throws XPathExpressionException { checkContext(context); return castAs( getXPathProcessor().evaluate(xpathExpression, context, returnXPathConstant(as)), as ); } /**
/** * Evaluate a string XPath expression relative to a node such as a node * returned by a previous XPath expression. * An XPath expression can return a Node or subinterface such as * Element or Text, a NodeList, or a Boolean, Number, or String value. * @param xpathExpression the XPath expression as a string * @param context the node for evaluating the expression * @param as the type expected to be matched by the xpath * @param <T> the type to return * @return the value produced by the XPath expression * @throws XPathExpressionException if xpathExpression cannot be evaluated */ public <T> T evaluateXPath(String xpathExpression, Node context, Class<T> as) throws XPathExpressionException { checkContext(context); return castAs( getXPathProcessor().evaluate(xpathExpression, context, returnXPathConstant(as)), as ); } /**