Assert that two XML documents are similar
@param control XML to be compared against
@param test XML to be tested
@throws SAXException
@throws IOException
430488
public static void assertXMLEqual(InputSource control, InputSource test)
        throws SAXException, IOException {
        assertXMLEqual(null, control, test);
    }
967050
public static void assertXMLEqual(String err, Reader control, Reader test)
        throws SAXException, IOException {
        Diff diff = new Diff(control, test);
        assertXMLEqual(err, diff, true);
    }
1068928
public static Diff compareXML(String control, String test)
        throws SAXException, IOException {
        return new Diff(control, test);
    }
363010
public static XPathUtils newXPath(final InputStream is)
            throws SAXException, IOException {
        final XPathFactory xpfactory = XPathFactory.newInstance();
        final XPath xPath = xpfactory.newXPath();
        final Document doc = XmlUtils.toDoc(is);
        return new XPathUtils(xPath, doc);
    }
920888
private void sameTextNode() throws TTIOException, XMLStreamException {
        // Update variables.
        mInsert = EInsert.NOINSERT;
        mDelete = EDelete.NODELETE;
        mInserted = false;
        mInsertedEndTag = false;
        mRemovedNode = false;

        // Check if last node reached.
        // checkIfLastNode(false);

        // Skip whitespace events.
        skipWhitespaces(mReader);

        // Move to right sibling if next node isn't an end tag.
        if (mReader.peek().getEventType() != XMLStreamConstants.END_ELEMENT) {
            // // Check if next node matches or not.
            // boolean found = false;
            // if (mReader.peek().getEventType() ==
            // XMLStreamConstants.START_ELEMENT) {
            // found = checkElement(mReader.peek().asStartElement());
            // } else if (mReader.peek().getEventType() ==
            // XMLStreamConstants.CHARACTERS) {
            // found = checkText(mReader.peek().asCharacters());
            // }
            //
            // // If next node doesn't match/isn't the same move on.
            // if (!found) {
            if (mWtx.moveTo(((ITreeStructData)mWtx.getNode()).getRightSiblingKey())) {
                mMovedToRightSibling = true;
            } else {
                mMovedToRightSibling = false;
            }
            // }
        }

        mInsert = EInsert.ATMIDDLEBOTTOM;
    }
116237
def add_control_scanning_to_xml(xml, enabled)
      if elem = REXML::XPath.first(xml, '//enableControlsScan')
        elem.attributes['enabled'] = enabled ? '1' : '0'
      else
        elem = REXML::Element.new('ControlsScan', xml.root)
        elem.add_element('enableControlsScan',
                         'enabled' => enabled ? '1' : '0')
      end
    end
966014
public static void assertXpathsNotEqual(String controlXpath,
                                            Document controlDocument,
                                            String testXpath,
                                            Document testDocument)
        throws XpathException {
        assertXpathEquality(controlXpath, controlDocument, testXpath,
                            testDocument, false);
    }
1091793
private ComparisonState compareCharacterData(CharacterData control,
                                                 XPathContext controlContext,
                                                 CharacterData test,
                                                 XPathContext testContext) {
        return compare(new Comparison(ComparisonType.TEXT_VALUE, control,
                                      getXPath(controlContext),
                                      control.getData(), getParentXPath(controlContext),
                                      test, getXPath(testContext),
                                      test.getData(), getParentXPath(testContext)));
    }
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);
  }
1205394
public static void main(String[] args) throws IOException, SAXException {
      if (args != null && args.length > 0) {
         validateXml(new URL(args[0]));
      } else {
         System.out.println(getXsd());
      }
   }
244701
public static void assertXpathExists(String xPathExpression, 
                                         InputSource control)
        throws IOException, SAXException, XpathException {
        Document inDocument = XMLUnit.buildControlDocument(control);
        assertXpathExists(xPathExpression, inDocument);
    }
26558
protected void compareHasChildNodes(Node control, Node test,
                                        DifferenceListener listener) throws DifferenceFoundException {
        Boolean controlHasChildren = hasChildNodes(control);
        Boolean testHasChildren = hasChildNodes(test);
        compare(controlHasChildren, testHasChildren, control, test,
                listener, HAS_CHILD_NODES);
    }
942500
public static void main(String[] args) throws TransformerConfigurationException, SAXException{
        XSDocument xsd = new XSDocument(new StreamResult(System.out), false, 4, null);
        xsd.startDocument();
        {
            String n1 = "http://www.example.com/N1";
            String n2 = "http://www.example.com/N2";
            xsd.xml().declarePrefix("n1", n1);
            xsd.xml().declarePrefix("n2", n2);
            xsd.startSchema(n1);
            {
                xsd.addImport(n2, "imports/b.xsd");
                xsd.startComplexType().name("MyType");
                {
                    xsd.startCompositor(Compositor.SEQUENCE);
                    xsd.startElement().ref(n1, "e1").endElement();
                    xsd.endCompositor();
                }
                xsd.endComplexType();
                xsd.startElement().name("root").type(n1, "MyType").endElement();
            }
            xsd.endSchema();
        }
        xsd.endDocument();
    }
309562
private ComparisonState compareXsiType(Attr controlAttr,
                                           XPathContext controlContext,
                                           Attr testAttr,
                                           XPathContext testContext) {
        boolean mustChangeControlContext = controlAttr != null;
        boolean mustChangeTestContext = testAttr != null;
        if (!mustChangeControlContext && !mustChangeTestContext) {
            return new OngoingComparisonState();
        }
        boolean attributePresentOnBothSides = mustChangeControlContext
            && mustChangeTestContext;

        try {
            QName controlAttrName = null;
            if (mustChangeControlContext) {
                controlAttrName = Nodes.getQName(controlAttr);
                controlContext.addAttribute(controlAttrName);
                controlContext.navigateToAttribute(controlAttrName);
            }
            QName testAttrName = null;
            if (mustChangeTestContext) {
                testAttrName = Nodes.getQName(testAttr);
                testContext.addAttribute(testAttrName);
                testContext.navigateToAttribute(testAttrName);
            }
            return
                compare(new Comparison(ComparisonType.ATTR_NAME_LOOKUP,
                                       controlAttr, getXPath(controlContext),
                                       controlAttrName, getParentXPath(controlContext),
                                       testAttr, getXPath(testContext),
                                       testAttrName, getParentXPath(testContext)))
                .andIfTrueThen(attributePresentOnBothSides,
                               compareAttributeExplicitness(controlAttr, controlContext,
                                                            testAttr, testContext))
                .andIfTrueThen(attributePresentOnBothSides,
                               new Comparison(ComparisonType.ATTR_VALUE,
                                              controlAttr, getXPath(controlContext),
                                              valueAsQName(controlAttr), getParentXPath(controlContext),
                                              testAttr, getXPath(testContext),
                                              valueAsQName(testAttr), getParentXPath(testContext)));
        } finally {
            if (mustChangeControlContext) {
                controlContext.navigateToParent();
            }
            if (mustChangeTestContext) {
                testContext.navigateToParent();
            }
        }
    }
776
protected void compareRecognizedXMLSchemaInstanceAttribute(Attr control,
                                                               Attr test,
                                                               DifferenceListener listener)
        throws DifferenceFoundException {
        Attr nonNullNode = control != null ? control : test;
        Difference d = 
            XMLConstants.W3C_XML_SCHEMA_INSTANCE_SCHEMA_LOCATION_ATTR
            .equals(nonNullNode.getLocalName())
            ? SCHEMA_LOCATION : NO_NAMESPACE_SCHEMA_LOCATION;

        if (control != null) {
            controlTracker.visited(control);
        }
        if (test != null) {
            testTracker.visited(test);
        }
        
        compare(control != null ? control.getValue() : ATTRIBUTE_ABSENT,
                test != null ? test.getValue() : ATTRIBUTE_ABSENT,
                control, test, listener, d);
    }
1278162
public static void assertXMLNotEqual(String err, Reader control, Reader test)
        throws SAXException, IOException {
        Diff diff = new Diff(control, test);
        assertXMLEqual(err, diff, false);
    }
910936
public static void assertXMLEqual(String msg, Diff diff,
                                      boolean assertion) {       
        if (assertion != diff.similar()) {
            fail(getFailMessage(msg, diff));
        }
    }