private static XPathExpression buildExpression ( String xPathExpression , NamespaceContext nsContext ) throws XPathExpressionException { XPath xpath = createXPathFactory ( ) . newXPath ( ) ; if ( nsContext != null ) { xpath . setNamespaceContext ( nsContext ) ; } return xpath . compile ( xPathExpression ) ; }
Construct a xPath expression instance with given expression string and namespace context . If namespace context is not specified a default context is built from the XML node that is evaluated against .