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.poka.util.XmlSax.java
public String getLLJLFileNameL() { Document doc = load(bankFile, false); Element rootElm = doc.getRootElement(); if (rootElm == null) { rootElm = doc.addElement("root"); }//from w ww . ja va2 s.c o m Element root1Elm = rootElm.element("lljlL"); if (root1Elm == null) { root1Elm = rootElm.addElement("lljlL"); root1Elm.setText("[0-9A-Z]*_1_[0-9]{4}_[0-9]{17}[.]FSN$"); writeToXml(doc, bankFile); return "[0-9A-Z]*_1_[0-9]{4}_[0-9]{17}[.]FSN$"; } else { return root1Elm.getTextTrim(); } }
From source file:com.poka.util.XmlSax.java
public String getLLJLFileNameC() { Document doc = load(bankFile, false); Element rootElm = doc.getRootElement(); if (rootElm == null) { rootElm = doc.addElement("root"); }/* w w w. jav a2 s . c o m*/ Element root1Elm = rootElm.element("lljlC"); if (root1Elm == null) { root1Elm = rootElm.addElement("lljlC"); root1Elm.setText("[0-9A-Z]*_2_[0-9]{4}_[0-9]{17}[.]FSN$"); writeToXml(doc, bankFile); return "[0-9A-Z]*_2_[0-9]{4}_[0-9]{17}[.]FSN$"; } else { return root1Elm.getTextTrim(); } }
From source file:com.poka.util.XmlSax.java
public boolean isNeedBreakQF() { Document doc = load(bankFile, false); Element rootElm = doc.getRootElement(); if (rootElm == null) { rootElm = doc.addElement("root"); }// w w w . j a va 2 s . co m Element root1Elm = rootElm.element("breadqf"); if (root1Elm == null) { root1Elm = rootElm.addElement("breadqf"); root1Elm.setText("0"); writeToXml(doc, bankFile); return false; } else { String tem = root1Elm.getTextTrim(); return tem.equals("1"); } }
From source file:com.poka.util.XmlSax.java
public boolean isNeedLogin() { Document doc = load(regis, false); Element rootElm = doc.getRootElement(); if (rootElm == null) { rootElm = doc.addElement("root"); }// www . ja v a 2s .c om Element root1Elm = rootElm.element("login"); if (root1Elm == null) { return false; } else { String tem = root1Elm.getTextTrim(); return tem.equals("0"); } }
From source file:com.poka.util.XmlSax.java
public boolean isRegist() { Document doc = load(regis, false); Element rootElm = doc.getRootElement(); if (rootElm == null) { rootElm = doc.addElement("root"); }/*from www .ja va 2s . c o m*/ Element root1Elm = rootElm.element("regist"); if (root1Elm == null) { return false; } else { String tem = root1Elm.getTextTrim(); String tem1 = RegistrationUtil.getRegistration(); return tem.equals(tem1); } }
From source file:com.pureinfo.common.namedvalue.action.TreenamedValueQueryAction.java
License:Open Source License
/** * //from w ww .j ava 2 s . co m */ private Document makeDoc() { Document doc = DocumentHelper.createDocument(); Element root = doc.addElement("tree-named-values"); for (int i = 0; i < m_defaults.length; i++) { if (m_defaults == null && m_nvs == null) { continue; } Element ele = root.addElement("values"); ele.addAttribute("level", "" + i + 1); ele.addAttribute("default", m_defaults[i] == null ? "" : m_defaults[i]); addValues(ele, m_nvs[i]); } return doc; }
From source file:com.pureinfo.dolphin.export.impl.XmlExporterImpl.java
License:Open Source License
/** * @see com.pureinfo.dolphin.export.IExporter#export(OutputStream, * DolphinExportGoods)/* w ww . jav a 2 s . c om*/ */ public void export(OutputStream _os, IExportGoods _goods) throws PureException { try { //1. to create XML element Document doc = DocumentHelper.createDocument(); Element root = doc.addElement(_goods.getName()); //2. to prepare column names if (!_goods.hasHeader()) { throw new PureRuntimeException(PureException.SETTING_MISSING, "headers required in goods"); } String[] colNames = _goods.getHeaders(); //3. to export data Object[] values; Iterator iter = _goods.iterator(); while (iter.hasNext()) { values = _goods.unpackGoods(iter.next()); exportRow(root, values, colNames); } //4. to output to stream new XMLWriter(_os, OutputFormat.createPrettyPrint()).write(doc); } catch (Exception ex) { throw new PureException(PureException.UNKNOWN, "", ex); } }
From source file:com.pureinfo.srm.action.CodeGetActionBase.java
License:Open Source License
/** * @return/*w w w . j av a 2 s. co m*/ */ private Document createErrorXML() { Document doc = DocumentHelper.createDocument(); Element xRoot = doc.addElement("responseXML"); addInfo(xRoot, "success", "false"); addInfo(xRoot, "value", "ERROR"); addInfo(xRoot, "msg", ""); return doc; }
From source file:com.pureinfo.srm.action.CodeGetActionBase.java
License:Open Source License
/** * @param _info/*from w w w .ja v a 2 s .co m*/ * @return */ private Document wrapInfo(CodeInfo _info) { Document doc = DocumentHelper.createDocument(); Element xRoot = doc.addElement("responseXML"); addInfo(xRoot, "success", "true"); addInfo(xRoot, "value", _info.value); if (_info.cross_boundary) { String sMsg = " " + _info.round + " "; addInfo(xRoot, "msg", sMsg); } return doc; }
From source file:com.pureinfo.srm.org.action.SubQueryAction.java
License:Open Source License
/** * @param _groups/* w w w . ja va 2s .c o m*/ * @return */ private Document groups2Doc(OPGroup[] _groups) { Document doc = DocumentHelper.createDocument(); Element xRoot = doc.addElement("datas"); Element xType = xRoot.addElement("types"); xType.addAttribute("default", _groups[0].sDefault); Element xOP = xType.addElement("type"); xOP.addText("----"); xOP.addAttribute("value", ""); for (int i = 0; i < _groups[0].options.length; i++) { xOP = xType.addElement("type"); xOP.addText(_groups[0].options[i][1]); xOP.addAttribute("value", _groups[0].options[i][0]); } if (_groups[1] == null) { Element xV1 = xRoot.addElement("level0"); xOP = xV1.addElement("org"); xOP.addText("----"); xOP.addAttribute("value", ""); } else { Element xV1 = xRoot.addElement("level0"); xV1.addAttribute("default", _groups[1].sDefault); xOP = xV1.addElement("org"); xOP.addText("----"); xOP.addAttribute("value", ""); for (int i = 0; i < _groups[1].options.length; i++) { xOP = xV1.addElement("org"); xOP.addText(_groups[1].options[i][1]); xOP.addAttribute("value", _groups[1].options[i][0]); if (_groups[1].options[i].length > 2) { xOP.addAttribute("code", _groups[1].options[i][2]); } } } if (_groups[2] == null) { Element xV1 = xRoot.addElement("level1"); xOP = xV1.addElement("org"); xOP.addText("----"); xOP.addAttribute("value", ""); } else { OPGroup group = _groups[2]; if (group.options.length == 0) { Element xV1 = xRoot.addElement("level1"); xV1.addAttribute("default", group.sDefault); xOP = xV1.addElement("org"); xOP.addText(""); xOP.addAttribute("value", ""); } else { Element xV1 = xRoot.addElement("level1"); xV1.addAttribute("default", group.sDefault); xOP = xV1.addElement("org"); xOP.addText("----"); xOP.addAttribute("value", ""); for (int i = 0; i < group.options.length; i++) { xOP = xV1.addElement("org"); xOP.addText(group.options[i][1]); xOP.addAttribute("value", group.options[i][0]); if (group.options[i].length > 2) { xOP.addAttribute("code", group.options[i][2]); } } } } if (_groups.length > 3 && _groups[3] != null) { OPGroup group = _groups[3]; if (group.options.length == 0) { Element xV1 = xRoot.addElement("level1_2"); xV1.addAttribute("default", group.sDefault); xOP = xV1.addElement("org"); xOP.addText(""); xOP.addAttribute("value", ""); } else { Element xV1 = xRoot.addElement("level1_2"); xV1.addAttribute("default", group.sDefault); xOP = xV1.addElement("org"); xOP.addText("----"); xOP.addAttribute("value", ""); for (int i = 0; i < group.options.length; i++) { xOP = xV1.addElement("org"); xOP.addText(group.options[i][1]); xOP.addAttribute("value", _groups[3].options[i][0]); if (group.options[i].length > 2) { xOP.addAttribute("code", group.options[i][2]); } } } } return doc; }