Core/src/main/java/org/openestate/io/core/XmlUtils.java
public static XPath newXPath(String expression, Document doc, String namespacePrefix) throws JaxenException {
        DOMXPath xpath = new DOMXPath(expression);
        //LOGGER.debug( "new xpath: " + xpath.debug() );
        if (doc != null && namespacePrefix != null) {
            Element root = XmlUtils.getRootElement(doc);
            String uri = StringUtils.trimToEmpty(root.getNamespaceURI());
            xpath.addNamespace(namespacePrefix, uri);
        }
        return xpath;
    }
public static XPath newXPath(String expression, Document doc, String namespacePrefix) throws JaxenException {
        DOMXPath xpath = new DOMXPath(expression);
        //LOGGER.debug( "new xpath: " + xpath.debug() );
        if (doc != null && namespacePrefix != null) {
            Element root = XmlUtils.getRootElement(doc);
            String uri = StringUtils.trimToEmpty(root.getNamespaceURI());
            xpath.addNamespace(namespacePrefix, uri);
        }
        return xpath;
    }
public static XPath newXPath ( String expression , Document doc , String namespacePrefix ) throws JaxenException { DOMXPath xpath = new DOMXPath ( expression ) ; //LOGGER.debug( "new xpath: " + xpath.debug() ); if ( doc != null && namespacePrefix != null ) { Element root = XmlUtils . getRootElement ( doc ) ; String uri = StringUtils . trimToEmpty ( root . getNamespaceURI ( ) ) ; xpath . addNamespace ( namespacePrefix , uri ) ; } return xpath ; }
Create a {@link XPath} expression.

@param expression      string with the XPath expression to create
@param doc             the document, whose namespace is bound to the XPath expression
@param namespacePrefix prefix of the document namespace, that is bound to the XPath expression
@return the created XPath expression
@throws JaxenException if the XPath is not creatable
Create a { @link XPath } expression .