@Override public void describeMismatch(Object item, Description description) { XpathEngine engine = XMLUnit.newXpathEngine(); engine.setNamespaceContext(namespaceContext); try { List<Node> nodes = nodeCollection(engine.getMatchingNodes(xPath, (Document) item)); matcher.describeMismatch(nodes, description); if (showXML != null) { printDom((Document) item, showXML); } } catch (XpathException e) { description.appendText("exception occured: ").appendText(e.getMessage()); } } };
/** * Execute the specified xpath syntax <code>select</code> expression * on the specified document and return the list of nodes (could have * length zero) that match * @param select * @param document * @return list of matching nodes */ public NodeList getMatchingNodes(String select, Document document) throws XpathException { try { return (NodeList) xpath.evaluate(select, document, XPathConstants.NODESET); } catch (XPathExpressionException ex) { throw new XpathException(ex); } }
/** * Evaluate the result of executing the specified xpath syntax * <code>select</code> expression on the specified document * @param select * @param document * @return evaluated result * @throws TransformerException * @throws TransformerConfigurationException */ public String evaluate(String select, Document document) throws XpathException { try { return xpath.evaluate(select, document); } catch (XPathExpressionException ex) { throw new XpathException(ex); } }
/** * Execute the specified xpath syntax <code>select</code> expression * on the specified document and return the list of nodes (could have * length zero) that match * @param select * @param document * @return list of matching nodes */ public NodeList getMatchingNodes(String select, Document document) throws ConfigurationException, XpathException { try { return getXPathResultNode(select, document).getChildNodes(); } catch (TransformerException ex) { throw new XpathException("Failed to apply stylesheet", ex); } }
@Override public void describeMismatch(Object item, Description description) { XpathEngine engine = XMLUnit.newXpathEngine(); engine.setNamespaceContext(namespaceContext); try { List<Node> nodes = nodeCollection(engine.getMatchingNodes(xPath, (Document) item)); matcher.describeMismatch(nodes, description); if (showXML != null) { printDom((Document) item, showXML); } } catch (XpathException e) { description.appendText("exception occured: ").appendText(e.getMessage()); } } };
/** * Execute the specified xpath syntax <code>select</code> expression * on the specified document and return the list of nodes (could have * length zero) that match * @param select * @param document * @return list of matching nodes */ public NodeList getMatchingNodes(String select, Document document) throws ConfigurationException, XpathException { try { return getXPathResultNode(select, document).getChildNodes(); } catch (TransformerException ex) { throw new XpathException("Failed to apply stylesheet", ex); } }
/** * Evaluate the result of executing the specified xpath syntax * <code>select</code> expression on the specified document * @param select * @param document * @return evaluated result */ public String evaluate(String select, Document document) throws ConfigurationException, XpathException { try { StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); performTransform(getValueTransformation(select), document, result); return writer.toString(); } catch (TransformerException ex) { throw new XpathException("Failed to apply stylesheet", ex); } }
/** * Evaluate the result of executing the specified xpath syntax * <code>select</code> expression on the specified document * @param select * @param document * @return evaluated result */ public String evaluate(String select, Document document) throws ConfigurationException, XpathException { try { StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); performTransform(getValueTransformation(select), document, result); return writer.toString(); } catch (TransformerException ex) { throw new XpathException("Failed to apply stylesheet", ex); } }
/** * Evaluate the result of executing the specified xpath syntax * <code>select</code> expression on the specified document * @param select * @param document * @return evaluated result * @throws XpathException */ public String evaluate(String select, Document document) throws XpathException { try { return engine.evaluate(select, new DOMSource(document)); } catch (XMLUnitException ex) { throw new XpathException(ex.getCause()); } }
/** * Execute the specified xpath syntax <code>select</code> expression * on the specified document and return the list of nodes (could have * length zero) that match * @param select * @param document * @return list of matching nodes */ public NodeList getMatchingNodes(String select, Document document) throws XpathException { try { return new NodeListForIterable(engine .selectNodes(select, new DOMSource(document)) ); } catch (XMLUnitException ex) { throw new XpathException(ex.getCause()); } }
throw new XpathException("failed to obtain an XSLT transformer" + " for XPath expression.");
throw new XpathException("failed to obtain an XSLT transformer" + " for XPath expression.");