Xml { public static Element loadFile(URL url) throws IOException, JDOMException { Path path = pathFromUrl(url); SAXBuilder builder = getSAXBuilderWithPathXMLResolver(false, path); Document jdoc = builder.build(url); return (Element) jdoc.getRootElement().detach(); }  static void resetResolver(); static Element loadFile(URL url); static Element loadFile(URL url, Element xmlQuery); static Element loadFile(Path file); synchronized static byte[] convertFileToUTF8ByteArray(Path file); synchronized static byte[] convertByteArrayToUTF8ByteArray(byte[] buf, String charsetName); static Element loadString(String data, boolean validate); static Element loadStream(InputStream input); static Element transform(Element xml, Path styleSheetPath); static Object unmarshall(Element xml, Class clazz); static Element transform(Element xml, Path styleSheetPath, Map<String, Object> params); static void transform(Element xml, Path styleSheetPath, OutputStream out); static void transformXml(Element xml, Path styleSheetPath, OutputStream out); static void transform(Element xml, String styleSheetPath, Result result); static Element transformWithXmlParam(Element xml, String styleSheetPath, String xmlParamName, String xmlParam); static void transformWithXmlParam(Element xml, Source xslt, Result result,
                                             String xmlParamName, String xmlParam); static void transform(Element xml, Path styleSheetPath, Result result, Map<String, Object> params); static void clearTransformerFactoryStylesheetCache(); static Path transformFOP(Path uploadDir, Element xml, String styleSheetPath); static void writeResponse(Document doc, OutputStream out); static String getString(Element data); static String getJSON(Element xml); static String stripNonValidXMLCharacters(String in); static Element getXmlFromJSON(String jsonAsString); static String getJSON(String xml); static String getString(DocType data); static String getString(Document data); static Object selectSingle(Element xml, String xpath, List<Namespace> theNSs); static Element selectElement(Element xml, String xpath); static Element selectElement(Element xml, String xpath, List<Namespace> theNSs); static List<?> selectNodes(Element xml, String xpath, List<Namespace> theNSs); static List<?> selectDocumentNodes(Element xml, String xpath, List<Namespace> theNSs); static List<?> selectNodes(Element xml, String xpath); static String selectString(Element xml, String xpath); static String selectString(Element xml, String xpath, List<Namespace> theNSs); static boolean selectBoolean(Element xml, String xpath); static boolean selectBoolean(Element xml, String xpath, List<Namespace> theNSs); static Number selectNumber(Element xml, String xpath); static Number selectNumber(Element xml, String xpath, List<Namespace> theNSs); static Set<String> filterElementValues(Element element,
                                                  ElementFilter elementFilter,
                                                  String elementName,
                                                  Namespace elementNamespace,
                                                  String attributeName); static Set<String> filterElementValues(Element element,
                                                  ElementFilter elementFilter,
                                                  String elementName,
                                                  Namespace elementNamespace,
                                                  String attributeName,
                                                  Namespace attributeNamespace); synchronized static void validate(Element xml); static void validate(Path schemaPath, Element xml); static Element validateInfo(Element xml, XmlErrorHandler eh, String schemaName); static Element validateInfo(Path schemaPath, Element xml, XmlErrorHandler eh, String schemaName); static String getXPathExpr(Content element); static String getXPathExpr(Attribute attribute); static boolean isXMLLike(String inXMLStr); static final Namespace xsiNS; static final NioPathAwareEntityResolver PATH_RESOLVER; }
@Test public void testLoadXml() throws Exception { Path path = Paths.get(XmlTest.class.getResource("xmltest/xml.xsd").toURI()); Element element = Xml.loadFile(path); assertXsdFile(element); final Path test = setupMemoryFs(path); element = Xml.loadFile(test.resolve(path.getFileName().toString())); assertXsdFile(element); }