List of usage examples for org.dom4j Document addElement
Element addElement(String name);
Element
node with the given name to this branch and returns a reference to the new node. From source file:com.liferay.jbpm.WorkflowComponentImpl.java
License:Open Source License
public String updateTaskXml(long taskId, String transition, Map parameterMap) throws WorkflowComponentException { Map errors = updateTask(taskId, transition, parameterMap); Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("results"); Iterator itr = errors.entrySet().iterator(); while (itr.hasNext()) { Map.Entry entry = (Map.Entry) itr.next(); String name = (String) entry.getKey(); String code = (String) entry.getValue(); Element el = root.addElement("error"); DocUtil.add(el, "name", name); DocUtil.add(el, "code", code); }//from w w w. j a va2 s .c o m return doc.asXML(); }
From source file:com.littcore.license.LicenseManager.java
/** * ??.//from w w w .j a va2 s . com * * @param license the license * @param targetFile */ public static void writeLicense(License license, File targetFile) throws IOException { Document document = DocumentHelper.createDocument(); document.addElement("license"); Element root = document.getRootElement(); // root.addElement("licenseId").setText(license.getLicenseId()); root.addElement("licenseType").setText(license.getLicenseType()); root.addElement("productName").setText(license.getProductName()); root.addElement("companyName").setText(license.getCompanyName()); root.addElement("customerName").setText(license.getCustomerName()); root.addElement("version").setText(license.getVersion().toString()); root.addElement("createDate").setText(FormatDateTime.formatDate(license.getCreateDate())); root.addElement("expiredDate").setText(FormatDateTime.formatDate(license.getExpiredDate())); root.addElement("signature").setText(license.getSignature()); XmlUtils.writeXml(targetFile, document); }
From source file:com.liveneo.plat.web.action.MakeLicfile.java
public static Document initLicFile(LicForm licForm) { Document doc = DocumentHelper.createDocument(); Element corporationEle = doc.addElement("Liveneo"); corporationEle.addAttribute("platformType", licForm.getPlatformType()); corporationEle.addAttribute("sid", licForm.getSid()); corporationEle.addAttribute("version", licForm.getF_version()); Element licElement = corporationEle.addElement("License"); licElement.addAttribute("genDate", licForm.getGenDate()); licElement.addAttribute("genTime", licForm.getGenTime()); licElement.addAttribute("type", licForm.getType()); licElement.addAttribute("version", licForm.getLic_version()); Element hostidEle = licElement.addElement("HostID"); hostidEle.setText(licForm.getHostID()); Element notesEle = licElement.addElement("Notes"); notesEle.setText(licForm.getNotes()); Element productEle = licElement.addElement("Product"); Element pdNameEle = productEle.addElement("Name"); Element pdDispEle = productEle.addElement("DisplayName"); Element pdVersion = productEle.addElement("Version"); pdNameEle.setText(licForm.getProductName()); pdDispEle.setText(licForm.getProductDisplayName()); pdVersion.setText(licForm.getProductVersion()); Element featuresEle = licElement.addElement("Features"); if (null != licForm.getFeatureList()) { for (FeatureForm ff : licForm.getFeatureList()) { Element feaEle = featuresEle.addElement("Feature"); feaEle.addAttribute("name", ff.getFeatureName()); Element disnameEle = feaEle.addElement("DisplayName"); disnameEle.setText(ff.getFeatureDisplayName()); Element fvalueEle = feaEle.addElement("Value"); fvalueEle.setText(ff.getFeatureValue()); Element fexpEle = feaEle.addElement("ExpirationDate"); fexpEle.setText(ff.getFeatureExpDate()); }//from w w w.j ava 2 s.co m } Element signElement = corporationEle.addElement("Signature"); signElement.setText(licForm.getSignature()); return doc; }
From source file:com.love320.templateparser.templateprocess.impl.SeparationImpl.java
License:Apache License
@Override public String getXML(String str) { Document document = DocumentHelper.createDocument();//?xml Element rootElement = document.addElement("root");// root rootElement.addElement("site").setText("www.love320.com");//? Element contentElement = rootElement.addElement("content");//?? for (String singStr : str.split("\r\n")) {//????? tagStrRow(singStr, contentElement);//??? addContent("/r/n", 3, contentElement);//? -- /r/n }//from w ww. ja v a 2 s .c o m return document.asXML();//xml }
From source file:com.ltmonitor.jt809.app.GlobalConfig.java
public static void setModel(ParameterModel pm) { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("config"); doc.setRootElement(root);/*from w w w .j av a 2 s.co m*/ Element pe = root.addElement("parameter"); pe.addAttribute("platip", pm.getPlatformIP()); pe.addAttribute("idletime", String.valueOf(pm.getIdleTime())); pe.addAttribute("localport", String.valueOf(pm.getLocalPort())); pe.addAttribute("platid", String.valueOf(pm.getPlatformCenterId())); pe.addAttribute("platport", String.valueOf(pm.getPlatformPort())); pe.addAttribute("platuserid", String.valueOf(pm.getPlatformUserName())); pe.addAttribute("platpassword", String.valueOf(pm.getPlatformPass())); pe.addAttribute("miyaom", String.valueOf(pm.getMiyaoM())); pe.addAttribute("miyaoa", String.valueOf(pm.getMiyaoA())); pe.addAttribute("miyaoc", String.valueOf(pm.getMiyaoC())); pe.addAttribute("protocolver", pm.getProtocolVer()); pe.addAttribute("localip", pm.getLocalIp()); pe.addAttribute("licenseno", pm.getLicenseNo()); pe.addAttribute("username", pm.getUsername()); try { FileWriter out = new FileWriter(CONFIG_PATH + "database.xml"); XmlUtils.printXml(doc, out); } catch (Exception ex) { //this.logger.warn("" + ex.getMessage()); } }
From source file:com.magicpwd._util.Jxml.java
License:Open Source License
public static void save(String file, MpwdHeader keys, List pwds) { Document doc = create(); // root element Element root = doc.addElement("MagicPwd").addAttribute("site", ConsEnv.HOMEPAGE); Element node = root.addElement("Key").addAttribute("type", "pwds"); node.addElement(Lang.getLang(LangRes.P30F1C01, "status")) .addAttribute("name", Lang.getLang(LangRes.P30F1C02, "?")) .setText(keys.getP30F0102() + ""); node.addElement(Lang.getLang(LangRes.P30F1C03, "catalog")) .addAttribute("name", Lang.getLang(LangRes.P30F1C04, "")).setText(keys.getP30F0106()); node.addElement(Lang.getLang(LangRes.P30F1C04, "create")) .addAttribute("name", Lang.getLang(LangRes.P30F1C06, "")) .setText(keys.getP30F0107().toString()); node.addElement(Lang.getLang(LangRes.P30F1C07, "title")) .addAttribute("name", Lang.getLang(LangRes.P30F1C08, "?")).setText(keys.getP30F0109()); node.addElement(Lang.getLang(LangRes.P30F1C09, "meta")) .addAttribute("name", Lang.getLang(LangRes.P30F1C0A, "?")).setText(keys.getP30F010A()); node.addElement(Lang.getLang(LangRes.P30F1C0B, "logo")) .addAttribute("name", Lang.getLang(LangRes.P30F1C0C, "?")).setText(keys.getP30F010B()); node.addElement(Lang.getLang(LangRes.P30F1C0D, "limit")) .addAttribute("name", Lang.getLang(LangRes.P30F1C0E, "")) .setText(keys.getP30F010E().toString()); node.addElement(Lang.getLang(LangRes.P30F1C0F, "hint")) .addAttribute("name", Lang.getLang(LangRes.P30F1C10, "??")).setText(keys.getP30F010F()); node.addElement(Lang.getLang(LangRes.P30F1C11, "memo")) .addAttribute("name", Lang.getLang(LangRes.P30F1C12, "")).setText(keys.getP30F0110()); }
From source file:com.magicpwd._util.Jxml.java
License:Open Source License
public static void save(String file, MpwdHeader keys) { Document doc = create(); // root element Element root = doc.addElement("MagicPwd").addAttribute("site", ConsEnv.HOMEPAGE); Element node = root.addElement("Key").addAttribute("type", "note"); node.addElement(Lang.getLang(LangRes.P30F1C03, "catalog")) .addAttribute("name", Lang.getLang(LangRes.P30F1C04, "")).setText(keys.getP30F0106()); node.addElement(Lang.getLang(LangRes.P30F1C07, "title")) .addAttribute("name", Lang.getLang(LangRes.P30F1C08, "?")).setText(keys.getP30F0109()); node.addElement(Lang.getLang(LangRes.P30F1C09, "meta")) .addAttribute("name", Lang.getLang(LangRes.P30F1C0A, "?")).setText(keys.getP30F010A()); node.addElement(Lang.getLang(LangRes.P30F1C0B, "logo")) .addAttribute("name", Lang.getLang(LangRes.P30F1C0C, "?")).setText(keys.getP30F010B()); node.addElement(Lang.getLang(LangRes.P30F1C11, "memo")) .addAttribute("name", Lang.getLang(LangRes.P30F1C12, "")).setText(keys.getP30F0110()); node.addElement(Lang.getLang(LangRes.P30F1C11, "content")) .addAttribute("name", Lang.getLang(LangRes.P30F1C12, "")) .setText(keys.getMpwd().getP30F0203().toString()); }
From source file:com.mindquarry.desktop.model.task.Task.java
License:Open Source License
public Document getContentAsXML() { Document doc = DocumentHelper.createDocument(); Element task = doc.addElement("task"); //$NON-NLS-1$ Element title = task.addElement("title"); //$NON-NLS-1$ title.setText(getTitle());//from w w w .j a v a 2 s . c o m if ((getPriority() != null) && (!getPriority().equals(""))) { //$NON-NLS-1$ Element priority = task.addElement("priority"); //$NON-NLS-1$ priority.setText(getPriority()); } if ((getSummary() != null) && (!getSummary().equals(""))) { //$NON-NLS-1$ Element summary = task.addElement("summary"); //$NON-NLS-1$ summary.setText(getSummary()); } if ((getStatus() != null) && (!getStatus().equals(""))) { //$NON-NLS-1$ Element status = task.addElement("status"); //$NON-NLS-1$ status.setText(getStatus()); } if ((getDate() != null) && (!getDate().equals(""))) { //$NON-NLS-1$ Element date = task.addElement("date"); //$NON-NLS-1$ date.setText(getDate()); } if ((getDescription() != null) && (!getDescription().equals(""))) { //$NON-NLS-1$ Element description = task.addElement("description"); //$NON-NLS-1$ description.setText(getDescription()); } if ((getTargetTime() != null) && (!getTargetTime().equals(""))) { //$NON-NLS-1$ Element description = task.addElement("targettime"); //$NON-NLS-1$ description.setText(getTargetTime()); } if ((getActualTime() != null) && (!getActualTime().equals(""))) { //$NON-NLS-1$ Element description = task.addElement("actualtime"); //$NON-NLS-1$ description.setText(getActualTime()); } if (people.size() > 0) { int count = 0; Element peopleEl = task.addElement("people"); //$NON-NLS-1$ for (Person person : people) { Element itemEl = peopleEl.addElement("item"); //$NON-NLS-1$ itemEl.addAttribute("position", String.valueOf(count)); //$NON-NLS-1$ Element personEl = itemEl.addElement("person"); //$NON-NLS-1$ personEl.addText(person.pid); Element roleEl = itemEl.addElement("role"); //$NON-NLS-1$ roleEl.addText(person.role); count++; } } if (dependencies.size() > 0) { int count = 0; Element dependenciesEl = task.addElement("dependencies"); //$NON-NLS-1$ for (Dependency dependency : dependencies) { Element itemEl = dependenciesEl.addElement("item"); //$NON-NLS-1$ itemEl.addAttribute("position", String.valueOf(count)); //$NON-NLS-1$ Element taskEl = itemEl.addElement("task"); //$NON-NLS-1$ taskEl.addText(dependency.tid); Element roleEl = itemEl.addElement("role"); //$NON-NLS-1$ roleEl.addText(dependency.role); count++; } } return doc; }
From source file:com.nokia.helium.internaldata.ant.listener.XMLRenderer.java
License:Open Source License
/** * Rendering the build node into XML string. */// w ww . j av a 2 s. co m public String toString() { // Creating the XML document Document document = DocumentHelper.createDocument(); Element statistics = document.addElement("statistics"); statistics.addAttribute("version", "1.1"); // Creating the document content. insertDatabase(statistics); createTargets(statistics); createAsserts(statistics); createExecutionTree(statistics); createProperties(statistics); try { ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLWriter out = new XMLWriter(output, OutputFormat.createPrettyPrint()); out.write(document); return output.toString(); } catch (UnsupportedEncodingException exc) { return document.asXML(); } catch (IOException exc) { return document.asXML(); } }
From source file:com.noterik.bart.fs.action.GenericIndexAction.java
License:Open Source License
/** * Create XML for an index/*w w w.ja v a 2s. c om*/ * * @param objectUri * @param objectDetails * @param collectionDetails * @param iConfig */ private static void makeTypeFromObject(String objectUri, Map<String, Object> objectDetails, Map<String, Object> collectionDetails, IndexConfig iConfig) { Document typeDocument = DocumentHelper.createDocument(); Element fsxml = typeDocument.addElement("fsxml"); Element type = fsxml.addElement(iConfig.getIndexType()); String objectType = iConfig.getIndexObject(); // add refer to original object Element referObject = type.addElement(objectType); referObject.addAttribute("id", "1"); referObject.addAttribute("referid", objectUri); //add refer to original collection, remove trailing slash, otherwise refer cannot be found! Element referCollectionObject = type.addElement("collection" + objectType); referCollectionObject.addAttribute("id", "1"); String collectionObject = (String) collectionDetails.get("object"); collectionObject = collectionObject.substring(0, collectionObject.length() - 1); referCollectionObject.addAttribute("referid", collectionObject); Element properties = type.addElement("properties"); //add standard properties properties.addElement(objectType).addText((String) collectionDetails.get("object")); properties.addElement(objectType + "uri").addText(objectUri + "/"); properties.addElement(objectType + "title").addText((String) objectDetails.get(objectType + "title")); properties.addElement(objectType + "description") .addText((String) objectDetails.get(objectType + "description")); properties.addElement(objectType + "screenshot") .addText((String) objectDetails.get(objectType + "screenshot")); //properties.addElement(objectType+"type").addText((String) objectDetails.get(objectType+"type")); //properties.addElement(objectType+"author").addText((String) objectDetails.get(objectType+"author")); //properties.addElement(objectType+"copyright").addText((String) objectDetails.get(objectType+"copyright")); //properties.addElement(objectType+"website").addText((String) objectDetails.get(objectType+"website")); properties.addElement("collection").addText((String) collectionDetails.get("collection")); //add user configured properties Map<String, String> items = iConfig.getProperties(); for (String item : items.keySet()) { if (item.equals("collectiontitle") || item.equals("collectiondescription") || item.equals("collectionstatus")) { properties.addElement(item).addText((String) collectionDetails.get(item)); } else if (item.equals("lockmode") || item.equals("date_created") || item.equals(objectType + "duration") || item.equals(objectType + "theme") || item.equals(objectType + "location") || item.equals(objectType + "date") || item.equals(objectType + "date_original") || item.equals(objectType + "public") || item.equals("sponsor")) { properties.addElement(item).addText((String) objectDetails.get(item)); } else if (item.equals("title") || item.equals("name")) { properties.addElement(item).addText((String) objectDetails.get(objectType + "title")); } else if (item.equals("description")) { properties.addElement(item).addText((String) objectDetails.get(objectType + "description")); } else if (item.equals("screenshot")) { properties.addElement(item).addText((String) objectDetails.get(objectType + "screenshot")); } else if (item.equals("rank")) { properties.addElement(item).addText("5"); } else if (item.equals("peercomments")) { properties.addElement(item).addText(getType((Document) objectDetails.get(objectType), "peercomments", 0.0, 86400000.0, new String[] { "comment" })); } else if (item.equals("bookmark")) { properties.addElement(item).addText(getType((Document) objectDetails.get(objectType), "bookmark", 0.0, 86400000.0, new String[] { "title", "description", "creator" })); } else if (item.equals("webtv_item_id") || item.equals(objectType + "livestate")) { properties.addElement(item).addText((String) objectDetails.get(item)); } else if (item.equals(objectType + "status") || item.equals(objectType + "theme") || item.equals(objectType + "time")) { properties.addElement(item).addText((String) objectDetails.get(item)); } } long timestamp = new Date().getTime(); type.addAttribute("id", String.valueOf(timestamp)); // Add directly to fs so maggie get's updated with first content faster FSXMLRequestHandler.instance().saveFsXml(iConfig.getIndexUri(), typeDocument.asXML(), "PUT", true); }