Assert that the node lists of two Xpaths in two documents are NOT equal
@param controlXpath
@param testXpath
@param controlDocument
@param testDocument
@see XpathEngine
966014
public static void assertXpathsNotEqual(String controlXpath,
                                            Document controlDocument,
                                            String testXpath,
                                            Document testDocument)
        throws XpathException {
        assertXpathEquality(controlXpath, controlDocument, testXpath,
                            testDocument, false);
    }
860666
public static void assertXpathEvaluatesTo(String expectedValue,
                                              String xpathExpression,
                                              InputSource control)
        throws SAXException, IOException,
               XpathException {
        Document document = XMLUnit.buildControlDocument(control);
        assertXpathEvaluatesTo(expectedValue, xpathExpression, document);
    }
405866
public static NodeList xpathNodeList(Node document, XPathExpression xpathExpression) throws XPathException, MarshallingException
    {
        return (NodeList) executeXPath(document, xpathExpression, XPathConstants.NODESET);
    }
113431
public boolean notEquals(XObject obj2)
          throws javax.xml.transform.TransformerException
  {

    // In order to handle the 'all' semantics of 
    // nodeset comparisons, we always call the 
    // nodeset function.
    if (obj2.getType() == XObject.CLASS_NODESET)
      return obj2.notEquals(this);

    return !equals(obj2);
  }
209619
public static void assertXpathEvaluatesTo(String expectedValue,
                                              String xpathExpression,
                                              Document inDocument)
        throws XpathException {
        XpathEngine simpleXpathEngine = XMLUnit.newXpathEngine();
        assertEquals(expectedValue,
                     simpleXpathEngine.evaluate(xpathExpression, inDocument));
    }
910936
public static void assertXMLEqual(String msg, Diff diff,
                                      boolean assertion) {       
        if (assertion != diff.similar()) {
            fail(getFailMessage(msg, diff));
        }
    }
592994
private void compareNodes(Context context) {
        if (shouldIgnorePath(context.getActualPath())) {
            return;
        }

        Node expectedNode = context.getExpectedNode();
        Node actualNode = context.getActualNode();

        NodeType expectedNodeType = expectedNode.getNodeType();
        NodeType actualNodeType = actualNode.getNodeType();

        Path fieldPath = context.getActualPath();

        //ignoring value
        if (expectedNodeType == NodeType.STRING && configuration.shouldIgnore(expectedNode.asText())) {
            return;
        }

        if (shouldIgnoreElement(expectedNode)) {
            return;
        }

        // Any number
        if (checkAny(NodeType.NUMBER, ANY_NUMBER_PLACEHOLDER, "a number", context)) {
            return;
        }

        // Any boolean
        if (checkAny(NodeType.BOOLEAN, ANY_BOOLEAN_PLACEHOLDER, "a boolean", context)) {
            return;
        }

        // Any string
        if (checkAny(NodeType.STRING, ANY_STRING_PLACEHOLDER, "a string", context)) {
            return;
        }

        if (checkMatcher(context)) {
            return;
        }

        if (!expectedNodeType.equals(actualNodeType)) {
            reportValueDifference(context, "Different value found in node \"%s\", " + differenceString() + ".", fieldPath, quoteTextValue(expectedNode), quoteTextValue(actualNode));
        } else {
            switch (expectedNodeType) {
                case OBJECT:
                    compareObjectNodes(context);
                    break;
                case ARRAY:
                    compareArrayNodes(context);
                    break;
                case STRING:
                    compareStringValues(context);
                    break;
                case NUMBER:
                    BigDecimal actualValue = actualNode.decimalValue();
                    BigDecimal expectedValue = expectedNode.decimalValue();
                    if (configuration.getTolerance() != null && !hasOption(IGNORING_VALUES)) {
                        BigDecimal diff = expectedValue.subtract(actualValue).abs();
                        if (diff.compareTo(configuration.getTolerance()) > 0) {
                            reportValueDifference(context, "Different value found in node \"%s\", " + differenceString() + ", difference is %s, tolerance is %s",
                                    fieldPath, quoteTextValue(expectedValue), quoteTextValue(actualValue), diff.toString(), configuration.getTolerance());
                        }
                    } else {
                        compareValues(context, expectedValue, actualValue);
                    }
                    break;
                case BOOLEAN:
                    compareValues(context, expectedNode.asBoolean(), actualNode.asBoolean());
                    break;
                case NULL:
                    //nothing
                    break;
                default:
                    throw new IllegalStateException("Unexpected node type " + expectedNodeType);
            }
        }
    }
64212
private ComparisonState nodeTypeSpecificComparison(Node control,
                                                       XPathContext controlContext,
                                                       Node test,
                                                       XPathContext testContext) {
        switch (control.getNodeType()) {
        case Node.CDATA_SECTION_NODE:
        case Node.COMMENT_NODE:
        case Node.TEXT_NODE:
            if (test instanceof CharacterData) {
                return compareCharacterData((CharacterData) control,
                                            controlContext,
                                            (CharacterData) test, testContext);
            }
            break;
        case Node.DOCUMENT_NODE:
            if (test instanceof Document) {
                return compareDocuments((Document) control, controlContext,
                                        (Document) test, testContext);
            }
            break;
        case Node.ELEMENT_NODE:
            if (test instanceof Element) {
                return compareElements((Element) control, controlContext,
                                       (Element) test, testContext);
            }
            break;
        case Node.PROCESSING_INSTRUCTION_NODE:
            if (test instanceof ProcessingInstruction) {
                return
                    compareProcessingInstructions((ProcessingInstruction) control,
                                                  controlContext,
                                                  (ProcessingInstruction) test,
                                                  testContext);
            }
            break;
        case Node.DOCUMENT_TYPE_NODE:
            if (test instanceof DocumentType) {
                return compareDocTypes((DocumentType) control, controlContext,
                                       (DocumentType) test, testContext);
            }
            break;
        case Node.ATTRIBUTE_NODE:
            if (test instanceof Attr) {
                return compareAttributes((Attr) control, controlContext,
                                         (Attr) test, testContext);
            }
            break;
        default:
            break;
        }
        return new OngoingComparisonState();
    }
960564
protected XmlElement findMatchedElementIn(Document document, org.dom4j.Element element) {
    org.dom4j.Attribute id = element.attribute("id");
    String idName = id.getName();
    String idValue = id.getValue();
    for (Element me : document.getRootElement().getElements()) {
      if (me instanceof XmlElement) {
        XmlElement xe = (XmlElement) me;
        for (Attribute ab : xe.getAttributes()) {
          if (StringUtils.equals(idName, ab.getName()) && StringUtils.equals(idValue, ab.getValue())) {
            return xe;
          }
        }
      }
    }
    return null;
  }
1013881
public static void writeXML(Document xmldocument, Writer writer) throws IOException {
		assert xmldocument != null : AssertMessages.notNullParameter(0);
		assert writer != null : AssertMessages.notNullParameter(1);
		writeNode(xmldocument, writer);
	}
910680
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());
        }
    }
961926
@Override
    boolean equivalentXml(Object target) {
        boolean result = false;

        if (target instanceof XML) {
            //    TODO    This is a horrifyingly inefficient way to do this so we should make it better.  It may also not work.
            return this.node.toXmlString(getProcessor()).equals( ((XML)target).node.toXmlString(getProcessor()) );
        } else if (target instanceof XMLList) {
            //    TODO    Is this right?  Check the spec ...
            XMLList otherList = (XMLList) target;

            if (otherList.length() == 1) {
                result = equivalentXml(otherList.getXML());
            }
        } else if (hasSimpleContent()) {
            String otherStr = ScriptRuntime.toString(target);

            result = toString().equals(otherStr);
        }

        return result;
    }
717546
public static void assertXMLNotEqual(InputSource control, InputSource test)
        throws SAXException, IOException {
        assertXMLNotEqual(null, control, test);
    }
99800
protected void compare(Object expected, Object actual,
                           Node control, Node test, DifferenceListener listener, Difference difference)
        throws DifferenceFoundException {
        compare(expected, actual, control, test, listener, difference,
                controlTracker, testTracker);
    }
445878
public static boolean recordingInfo(String testName) throws ParserConfigurationException, SAXException, IOException {
    TECore.rootTestName.clear();
    String path = getBaseConfigDirectory() + "/config.xml";
    if (new File(path).exists()) {
        // Fortify Mod: prevent external entity injection
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setExpandEntityReferences(false);
        DocumentBuilder db = dbf.newDocumentBuilder();
        //DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        Document doc = db.parse(path);
        NodeList nodeListForStandardTag = doc.getElementsByTagName("standard");
        if (null!=nodeListForStandardTag && nodeListForStandardTag.getLength() > 0) {
          for (int i = 0; i < nodeListForStandardTag.getLength(); i++) {
            Element elementStandard = (Element) nodeListForStandardTag.item(i);
            if (testName.equals(elementStandard.getElementsByTagName("local-name").item(0).getTextContent())) {
              if (null!=elementStandard.getElementsByTagName("record").item(0)) {
                System.setProperty("Record", "True");
                NodeList rootTestNameArray=elementStandard.getElementsByTagName("test-name");
                if (null!=rootTestNameArray && rootTestNameArray.getLength() > 0) {
                  for (int counter = 0; counter < rootTestNameArray.getLength(); counter++) {
                    Element rootTestName = (Element) rootTestNameArray.item(counter);
                    TECore.rootTestName.add(rootTestName.getTextContent());
                  }
                }
                return true;
              }
            }
    
          }
        }
    }
    System.setProperty("Record", "False");
    return false;
  }
867583
public static void assertXpathExists(String xPathExpression, 
                                         String inXMLString)
        throws IOException, SAXException, XpathException {
        Document inDocument = XMLUnit.buildControlDocument(inXMLString);
        assertXpathExists(xPathExpression, inDocument);
    }
219969
def xml_compare(expected, found):
    

    # if comparing the same ET object
    if expected == found:
        return True

    # compare element attributes, ignoring order
    if set(expected.items()) != set(found.items()):
        return False

    # check for equal number of children
    expected_children = list(expected)
    found_children = list(found)
    if len(expected_children) != len(found_children):
        return False

    # compare children
    if not all([xml_compare(a, b) for a, b in zip(expected_children, found_children)]):
        return False

    # compare elements, if there is no text node, return True
    if (expected.text is None or expected.text.strip() == "") \
        and (found.text is None or found.text.strip() == ""):
        return True
    else:
        return expected.tag == found.tag and expected.text == found.text \
            and expected.attrib == found.attrib