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); }
public XmlConfig() { try { Document doc = MXml.createDocument(); element = doc.createElement("config"); if (element!=null) name = element.getNodeName(); doc.appendChild(element); } catch (Exception e) {} }
public static String getValue(Element root, String path, String def) { Element ele = getElementByPath(root, path); if (ele == null) return def; return getValue(ele, false); }
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); }
return encode(key);
void doUpdate(Element xml) { id = xml.getAttribute("id"); name = xml.getAttribute("name"); incoming.clear(); for (Element eIn : MXml.getLocalElementIterator(xml, "bpmn2:incoming")) { String ref = MXml.getValue(eIn, false); if (ref.startsWith(XElement.SEQUENCE_FLOW)) { ref = ref.substring(XElement.SEQUENCE_FLOW.length()); ref = MString.beforeIndex(ref, '_'); } incoming.add(ref); } outgoing.clear(); for (Element eOut : MXml.getLocalElementIterator(xml, "bpmn2:outgoing")) { String ref = MXml.getValue(eOut, false); if (ref.startsWith(XElement.SEQUENCE_FLOW)) { ref = ref.substring(XElement.SEQUENCE_FLOW.length()); ref = MString.afterIndex(ref, '_'); } outgoing.add(ref); } }
/** * 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); }
@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(); }
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) { String id = MXml.getValue(repo, "id", ""); boolean hasReleases = MCast.toboolean(MXml.getValue(repo, "releases/enabled","true"), false); boolean hasStapshots = MCast.toboolean(MXml.getValue(repo, "snapshots/enabled","true"), false); String url = MXml.getValue(repo, "url", null); if (url == null) continue; String protocol = MString.beforeIndex(url, ':'); String[] rules = MXml.getValue(mirror, "mirrorOf", "").split(","); boolean ok = false; for (String rule : rules) { useMirrorId = MXml.getValue(useMirror, "id", ""); url = MXml.getValue(useMirror, "url", null); protocol = MString.beforeIndex(url, ':'); break; if (!MXml.getValue(proxy, "active", "").equals("true")) continue; if (protocol.equals(MXml.getValue(proxy, "protocol", ""))) { useProxy = proxy; useProxyId = MXml.getValue(useProxy, "host", ""); break;
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);
@Override public String getProperty(String key) { if (element==null || key==null) return null; if (VALUE.equals(key)) { // special key return MXml.getValue(element, false); } String out = element.getAttribute(key); if ( out == null || out.length() == 0 ) return null; return out; }
public static void saveXml(Node e, File out) throws Exception { FileOutputStream fo = new FileOutputStream(out); saveXml(e, fo); fo.close(); }
for (Element e : MXml.getLocalElementIterator(from, "attribute")) index.put(e.getAttribute("name"), e); CDATASection cdata = MXml.findCDataSection(a); if (cdata != null) { String data = cdata.getData();
@Override public IConfig getNode(String key) { Element e = MXml.getElementByPath(element, key); if (e == null) return null; return new XmlConfig(this, e); }
private static void toConfig(DefComponent node, Element xml) { for ( Element element : MXml.getLocalElementIterator(xml)) { DefComponent nextNode = new DefComponent( element.getNodeName() ); NamedNodeMap attrList = element.getAttributes(); for (int i = 0; i < attrList.getLength(); i++) { Node attrXml = attrList.item(i); nextNode.addAttribute(attrXml.getNodeName(), element.getAttribute(attrXml.getNodeName())); } node.addDefinition(nextNode); toConfig(nextNode, element); } }
/** {@inheritDoc} */ @Override public void focused(LayoutElement element) { String msg = ""; String t = element.getTitle(); if (t != null) msg = msg + "<b>" + MXml.encode(t) + "</b><br/>"; t = element.getErrorMessage(); if (t != null) msg = msg + "<font color=red>" + MXml.encode(t) + "</font><br/>"; t = element.getDescription(); if (t != null) msg = msg + MXml.encode(t) + "<br/>"; try { element.getDataSource().setString( name, msg ); } catch (Throwable e) { e.printStackTrace(); } }
for (Element child : MXml.getLocalElementIterator(elem)) { String eName = child.getNodeName(); if (eName.equals("bpmn2:outgoing")) { outgoingRef = MXml.getValue(eOutgoing, false);
public void readConfig(Reader file) throws Exception { Document config = MXml.loadXml(file); file.close(); if (element!=null) element = config.getDocumentElement(); name = element.getNodeName(); }