DomUtils { public static Document parseDocument(String inputData, boolean validating) throws ParserConfigurationException, SAXException, IOException { return parseDocument(new StringReader(inputData), validating); }  static Document parseDocument(String inputData, boolean validating); static Document parseDocument(Reader inputData, boolean validating); static Document parseDocument(File file, boolean validating); static Document parseDocument(InputStream is, boolean validating); static Document parseDocument(String inputData); static Document parseDocument(Reader inputData); static Document parseDocument(File file); static Document parseDocument(InputStream inputData); static boolean isAncestor(Node ancestor, Node node); static boolean hasAncestor(Node node, String ancestorName); static Node getAncestor(Node node, String ancestorName); static Node getAncestor(Node node, String[] ancestorNames); static Element getClosestAncestorWithAttribute(Node node, String ancestorName, String attributeName); static String getAttributeFromClosestAncestorOfAnyKind(Node node, String attributeName); static Node getHighestLevelAncestor(Node node, String ancestorName); static Element getNextSiblingElement(Element e); static Element getPreviousSiblingElement(Element e); static Element getNextSiblingElementByTagName(Element e, String name); static Element getPreviousSiblingElementByTagName(Element e, String name); static Element getFirstChildElement(Element e); static Element getLastChildElement(Element e); static Element getFirstElementByTagName(Node n, String name); static Element getLastElementByTagName(Element e, String name); static boolean isFirstOfItsKindIn(Node node, String ancestorName); static boolean isFirstOfItsKindIn(Node node, Node ancestor); static boolean isLastOfItsKindIn(Node node, String ancestorName); static boolean isLastOfItsKindIn(Node node, Node ancestor); static Element getPreviousOfItsKindIn(Element element, Element root); static Element getNextOfItsKindIn(Element element, Element root); static Element closestCommonAncestor(Node first, Node last); static Element encloseNodesWithNewElement(Node first, Node last, String newElementName); static List<Node> getNodeListAsList(NodeList nl); static String getPlainTextBelow(Node n); static void insertAfter(Node newNode, Node refNode); static void trimAllTextNodes(Node root); static String serializeToString(Document doc); static String document2String(Document document); static void document2File(Document document, File file); static void document2Stream(Document document, OutputStream target); static void replaceElement(Element oldElement, NodeList newNodes); static TreeWalker createTreeWalker(Document doc, Node root, String... tagNames); static TreeWalker createTreeWalker(Node root, String... tagNames); static NodeIterator createNodeIterator(Document doc, Node root, String... tagNames); static NodeIterator createNodeIterator(Node root, String... tagNames); static void trimEmptyTextNodes(Node node); static void compareNodes(Node expected, Node actual, boolean trimEmptyTextNodes);  }
@Test public void validatingParseString() throws Exception { String docAsString = IOUtils.toString(DomUtilsTest.class.getResourceAsStream("sample.maryxml"), "UTF-8"); DomUtils.parseDocument(docAsString, true); }
@Test public void validatingParseStream() throws Exception { DomUtils.parseDocument(DomUtilsTest.class.getResourceAsStream("sample.maryxml"), true); }