/** * Create a XML Document from a string. * * @param xml * @return the xml model * @throws ParserConfigurationException * @throws SAXException * @throws IOException */ public static Document loadXml(String xml) throws ParserConfigurationException, SAXException, IOException { return loadXml(xml, MString.CHARSET_UTF_8); }
public void readConfig(Reader file) throws Exception { Document config = MXml.loadXml(file); file.close(); if (element!=null) element = config.getDocumentElement(); name = element.getNodeName(); }
public static void load(XmlModel model, File file) throws Exception { Document doc = MXml.loadXml(file); Element eProcess = MXml.getElementByPath(doc.getDocumentElement(), "bpmn2:process"); model.load(eProcess); }
@Override public CompiledString compileString(String in) throws ParseException { try { Document xml = MXml.loadXml(in); Element rootElement = xml.getDocumentElement(); if (!rootElement.getNodeName().equals("common")) throw new ParseException("xml is not in common language, need to start with the tag <common>",in); return new CompiledString(new StringPart[] {}); } catch (Exception e) { throw new ParseException(in,e); } }
public static void saveInto(XmlModel model, File file) throws Exception { if (!file.exists()) { createDocument(model, file); return; } Document doc = MXml.loadXml(file); Element eProcess = MXml.getElementByPath(doc.getDocumentElement(), "bpmn2:process"); for (Element child : MXml.getLocalElementIterator(eProcess)) eProcess.removeChild(child); model.createXml(eProcess); MXml.saveXml(doc.getDocumentElement(), file); }
@Override public InputStream rewriteContent(String file, InputStream in) throws Exception { if (!file.equals(SOfficeConnector.SOFFICE_CONTENT)) return in; Document content = MXml.loadXml(in); NodeList list = content.getDocumentElement().getElementsByTagName("text:user-field-decl"); for (int i = 0; i < list.getLength(); i++) { Element node = (Element) list.item(i); String name = node.getAttribute("text:name"); String value = values.getString(name, null); if (value != null) { node.setAttribute("office:string-value", value); } } StreamBuffer buffer = new StreamBuffer(); MXml.saveXml(content, buffer.getOutputStream()); return buffer.getInputStream(); }
public static List<Artifact> findLocalArtifacts(String groupId) { getLocalRepositoryLocation(); File start = new File(repositoryLocation + "/" + MFile.normalizePath(groupId.replace('.', '/')) ); List<File> pomList = MFile.findAllFiles(start, new FileFilter() { @Override public boolean accept(File file) { return (file.isDirectory() || file.isFile() && file.getName().endsWith(".pom")); } }); LinkedList<Artifact> out = new LinkedList<>(); for (File pomFile : pomList) { try { Document pom = MXml.loadXml(pomFile); Artifact artifact = new Artifact(pom.getDocumentElement()); out.add(artifact); } catch (Throwable t) { } } return out; }
File settingsFile = new File(MSystem.getUserHome() + "/.m2/settings.xml"); if (settingsFile.exists() && settingsFile.isFile()) { Document settings = MXml.loadXml(settingsFile); MXml.getElementsByPath(settings.getDocumentElement(), path, out); File settingsFile = new File(System.getenv("MAVEN_HOME") + "/conf/settings.xml"); if (settingsFile.exists() && settingsFile.isFile()) { Document settings = MXml.loadXml(settingsFile); MXml.getElementsByPath(settings.getDocumentElement(), path, out);
return new XmlConfig(MXml.loadXml(configString).getDocumentElement()); } catch (Exception e) { throw new MException(configString,e);
Document doc = MXml.loadXml("<repository><id>central</id><name>Central Repository</name><url>http://repo.maven.apache.org/maven2</url></repository>"); repos.add(doc.getDocumentElement()); } catch (Throwable t) {