List of usage examples for org.dom4j DocumentHelper createDocument
public static Document createDocument()
From source file:com.pureinfo.srm.project.action.CardIdGenerateAction.java
License:Open Source License
/** * @return/* ww w. ja v a2 s . c o m*/ */ private Document makeResponseXML() { Document doc = DocumentHelper.createDocument(); Element xRoot = doc.addElement("responseXML"); Element xValue = xRoot.addElement("value"); xValue.setText(m_sCardId); Element xMSG = xRoot.addElement("msg"); xMSG.setText(m_sMessage); return doc; }
From source file:com.pureinfo.srm.reports.table.data.institute.InstituteQueryAction.java
License:Open Source License
private Document makeXML(List _sListIns) { Document doc = DocumentHelper.createDocument(); Element xRoot = doc.addElement("datas"); Element inses = xRoot.addElement("inses"); for (Iterator iter = _sListIns.iterator(); iter.hasNext();) { Organization org = (Organization) iter.next(); int id = org.getId(); String sName = org.getName(); Element xIns = inses.addElement("ins"); xIns.addAttribute("id", Integer.toString(id)); xIns.addAttribute("name", sName); xIns.addAttribute("code", org.getCode()); }//from ww w . j a v a2s . co m return doc; }
From source file:com.pureinfo.srm.weight.action.QueryWeightConfigAction.java
License:Open Source License
/** * @see com.pureinfo.ark.interaction.ActionBase#executeAction() *//*from w w w . j a v a2s. c om*/ public ActionForward executeAction() throws PureException { int year = request.getRequiredInt("weightYear", "weight year"); IWeightConfigMgr mgr = (IWeightConfigMgr) ArkContentHelper.getContentMgrOf(SRMTypes.WEIGHTCONFIG); boolean bExist = mgr.checkWeightExist(year); StringBuffer sbuff = new StringBuffer(); sbuff.append("<select id=\"id_isViewProbWeight\" name=\"isViewProbWeight\">"); sbuff.append("<option value=\"1\"></option>"); if (bExist) { sbuff.append("<option value=\"0\"></option>"); } sbuff.append("</select>"); try { Document document = DocumentHelper.createDocument(); Element element = document.addElement("result"); element.setText(sbuff.toString()); response.setCharacterEncoding("utf-8"); response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1 response.setHeader("Pragma", "no-cache"); // HTTP 1.0 response.getWriter().write(sbuff.toString()); } catch (IOException ex1) { ex1.printStackTrace(System.err); } finally { sbuff.setLength(0); } return null; }
From source file:com.qagen.osfe.programData.readerWriter.ReaderWriter.java
License:Apache License
public ReaderWriter(String fileName) { document = DocumentHelper.createDocument(); this.fileName = RESOURCE_PACKAGE + SLASH + fileName + SLASH + "config.xml"; }
From source file:com.rowtheboat.gui.OptionsSingleton.java
License:Open Source License
/** * This method saves the options to the options.xml file *///ww w .j av a 2s . co m public void saveOptions() throws SAXException, IOException { /* Start the document */ OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(new FileWriter(optionsFile), format); writer.startDocument(); /* Add the main options section */ Document document = DocumentHelper.createDocument(); Element root = document.addElement("Options"); /* Standard options */ DefaultElement standardElement = new DefaultElement("Standard"); standardElement.addElement("FullStrokeData").addText(getFullStrokeData() + ""); standardElement.addElement("BoatSmoothing").addText(getBoatSmoothing() + ""); root.add(standardElement); /* Input options */ DefaultElement inputElement = new DefaultElement("Input"); inputElement.addElement("SerialPort").addText(getSerialPort()); root.add(inputElement); /* Race options */ DefaultElement raceElement = new DefaultElement("Race"); raceElement.addElement("Countdown").addText(getDelay() + ""); root.add(raceElement); /* End the document */ writer.write(root); writer.endDocument(); writer.close(); }
From source file:com.sammyun.util.XmlHelper.java
License:Open Source License
/** * Dto??XML?(?)//from w w w . jav a 2s. c o m * * @param dto Dto * @param pRootNodeName ?? * @return string XML? */ public static final String parseDto2Xml(Dto pDto, String pRootNodeName) { if (EduUtil.isEmpty(pDto)) { logger.warn("DTO,"); return "<root />"; } Document document = DocumentHelper.createDocument(); // document.addElement(pRootNodeName); Element root = document.getRootElement(); Iterator keyIterator = pDto.keySet().iterator(); while (keyIterator.hasNext()) { String key = (String) keyIterator.next(); String value = pDto.getAsString(key); Element leaf = root.addElement(key); leaf.setText(value); } // XML? String outXml = document.asXML().substring(39); return outXml; }
From source file:com.sammyun.util.XmlHelper.java
License:Open Source License
/** * Dto??XML?(?)/*from w ww. j ava 2 s . c o m*/ * * @param pDto Dto * @param pRootNodeName ?? * @param pFirstNodeName ?? * @return string XML? */ public static final String parseDto2Xml(Dto pDto, String pRootNodeName, String pFirstNodeName) { if (EduUtil.isEmpty(pDto)) { logger.warn("DTO,"); return "<root />"; } Document document = DocumentHelper.createDocument(); // document.addElement(pRootNodeName); Element root = document.getRootElement(); root.addElement(pFirstNodeName); Element firstEl = (Element) document.selectSingleNode("/" + pRootNodeName + "/" + pFirstNodeName); Iterator keyIterator = pDto.keySet().iterator(); while (keyIterator.hasNext()) { String key = (String) keyIterator.next(); String value = pDto.getAsString(key); firstEl.addAttribute(key, value); } // XML? String outXml = document.asXML().substring(39); return outXml; }
From source file:com.sammyun.util.XmlHelper.java
License:Open Source License
/** * List???XML?(?)/*from w ww . ja va2 s .co m*/ * * @param pList List?(List?Dto?VO?Domain) * @param pRootNodeName ?? * @param pFirstNodeName ?? * @return string XML? */ public static final String parseList2Xml(List pList, String pRootNodeName, String pFirstNodeName) { Document document = DocumentHelper.createDocument(); Element elRoot = document.addElement(pRootNodeName); for (int i = 0; i < pList.size(); i++) { Dto dto = (Dto) pList.get(i); Element elRow = elRoot.addElement(pFirstNodeName); Iterator it = dto.entrySet().iterator(); while (it.hasNext()) { Dto.Entry entry = (Dto.Entry) it.next(); elRow.addAttribute((String) entry.getKey(), String.valueOf(entry.getValue())); } } String outXml = document.asXML().substring(39); return outXml; }
From source file:com.sammyun.util.XmlHelper.java
License:Open Source License
/** * List???XML?(?)// w w w . j a va 2 s .c o m * * @param pList List?(List?Dto?VO?Domain) * @param pRootNodeName ?? * @param pFirstNodeName ?? * @return string XML? */ public static final String parseList2XmlBasedNode(List pList, String pRootNodeName, String pFirstNodeName) { Document document = DocumentHelper.createDocument(); Element output = document.addElement(pRootNodeName); for (int i = 0; i < pList.size(); i++) { Dto dto = (Dto) pList.get(i); Element elRow = output.addElement(pFirstNodeName); Iterator it = dto.entrySet().iterator(); while (it.hasNext()) { Dto.Entry entry = (Dto.Entry) it.next(); Element leaf = elRow.addElement((String) entry.getKey()); leaf.setText(String.valueOf(entry.getValue())); } } String outXml = document.asXML().substring(39); return outXml; }
From source file:com.sf.integration.warehouse.service.SFService.java
/** * ?()/* w ww . jav a 2 s .c o m*/ * @param dctx * @param context * @return */ @SuppressWarnings("unchecked") public static Map<String, Object> querySFProductBySku(DispatchContext dctx, Map<String, Object> context) { Document doc = (Document) DocumentHelper.createDocument(); //Request Element request = doc.addElement("Request"); request.addAttribute("service", "ITEM_QUERY_SERVICE"); request.addAttribute("lang", "zh-CN"); //Head Element head = request.addElement("Head"); Element AccessCode = head.addElement("AccessCode"); AccessCode.setText(ACCESS_CODE);//? Element Checkword = head.addElement("Checkword"); Checkword.setText(CHECK_WORD);//?? //Body Element Body = request.addElement("Body"); Element ItemQueryRequest = Body.addElement("ItemQueryRequest"); Element CompanyCode = ItemQueryRequest.addElement("CompanyCode"); CompanyCode.setText(COMPANY_CODE);//? Element SkuNoList = ItemQueryRequest.addElement("SkuNoList"); List<String> skuNoList = (List<String>) context.get("skuNoList"); for (String skuNo : skuNoList) { Element SkuNo = SkuNoList.addElement("SkuNo"); SkuNo.setText(skuNo);//?? } String result = ""; String XMLStr = doc.getRootElement().asXML(); try { result = sendSFRequest(XMLStr); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ServiceUtil.returnSuccess(result); }