List of usage examples for org.dom4j Element add
void add(Namespace namespace);
Namespace
to this element. From source file:com.ibm.cognos.API.java
License:Open Source License
public void addListGroup(String p_sName) { Element n = (Element) oDocument.selectSingleNode( "/report/layouts/layout/reportPages/page/pageBody/contents/list/" + "listColumns/listGroups"); if (n == null) { addListGroups();//from ww w . ja v a2 s. co m n = (Element) oDocument.selectSingleNode( "/report/layouts/layout/reportPages/page/pageBody/contents/list/" + "listColumns/listGroups"); } // Add the listGroup node to listGroups Element eListGroup = DocumentHelper.createElement("listGroup"); n.addAttribute("refDataItem", p_sName); n.add(eListGroup); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addDetailFilter() { Element n = (Element) oDocument.selectSingleNode("/report/queries/query"); if (n == null) { addQuery();/*from www .ja v a2 s.c om*/ n = (Element) oDocument.selectSingleNode("/report/queries/query"); } Element eDetailFilter = DocumentHelper.createElement("detailFilter"); n.add(eDetailFilter); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addFilter() { Element n = (Element) oDocument.selectSingleNode("/report/queries/query/detailFilter"); if (n == null) { addDetailFilter();/*from w w w . j a va2s.c o m*/ n = (Element) oDocument.selectSingleNode("/report/queries/query/detailFilter"); } Element eFilter = DocumentHelper.createElement("filter"); eFilter.addAttribute("use", "required"); n.add(eFilter); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addFilterExpression(String filter) { Element n = (Element) oDocument.selectSingleNode("/report/queries/query/detailFilter/filter"); if (n == null) { addFilter();//from w w w.j a v a 2 s . c o m n = (Element) oDocument.selectSingleNode("/report/queries/query/detailFilter/filter"); } Element eFilterExpression = DocumentHelper.createElement("filterExpression"); eFilterExpression.setText(filter); n.add(eFilterExpression); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addSortList() { Element n = (Element) oDocument .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list"); if (n == null) { addList();/*from w ww. ja v a 2 s . co m*/ n = (Element) oDocument .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list"); } Element eSortList = DocumentHelper.createElement("sortList"); n.add(eSortList); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addDataItemSort(String p_sElementName, String p_sSort) { Element n = (Element) oDocument .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list/sortList"); if (n == null) { addSortList();/* w w w .j a va 2s. com*/ n = (Element) oDocument .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list/sortList"); } Element eSort = DocumentHelper.createElement("sortItem"); eSort.addAttribute("refDataItem", p_sElementName); eSort.addAttribute("sortOrder", p_sSort); n.add(eSort); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void modifyTitle(String title, String newTitle) { Element n = null;//from w w w. j a va 2 s.c om String quotChar = "\'"; if (title.indexOf(quotChar) >= 0) { quotChar = "\""; } String nodeDataItemTitle = "/report/layouts/layout/reportPages/page/pageBody/contents/list/listColumns/" + "listColumn/listColumnTitle/contents/textItem/dataSource/dataItemLabel[@refDataItem=" + quotChar + title + quotChar + "]"; String nodeStaticTitle = "/report/layouts/layout/reportPages/page/pageBody/contents/list/listColumns/" + "listColumn/listColumnTitle/contents/textItem/dataSource/staticValue"; n = (Element) oDocument.selectSingleNode(nodeDataItemTitle); if (n == null) { n = (Element) oDocument.selectSingleNode(nodeStaticTitle); if (n == null) { System.out.println("Modify column title failed for " + title + " title not found."); return; } } Element nDataSource = n.getParent(); n.detach(); Element eTitle = DocumentHelper.createElement("staticValue"); eTitle.setText(newTitle); nDataSource.add(eTitle); }
From source file:com.ibm.cognos.API.java
License:Open Source License
/** * addListColumn/*from w w w. j a v a 2s .c om*/ * * @param p_sName * @param position * (to insert in the default position pass 0 to this method) * (default position = insert after the last child element.) */ public void addListColumn(String p_sName, int position) { Element n = null; n = (Element) oDocument.selectSingleNode( "/report/layouts/layout/reportPages/page/pageBody/contents" + "/list/listColumns"); // Create an empty column node Element eCol = DocumentHelper.createElement("listColumn"); // Prepare all the bits to contain the column title Element eTitle = DocumentHelper.createElement("listColumnTitle"); Element eStyleTitle = buildStyle("lt"); Element eTContents = DocumentHelper.createElement("contents"); Element eTText = DocumentHelper.createElement("textItem"); Element eTSrc = DocumentHelper.createElement("dataSource"); Element eLabel = DocumentHelper.createElement("dataItemLabel"); eLabel.addAttribute("refDataItem", p_sName); // Prepare all the bits to contain the column data Element eBody = DocumentHelper.createElement("listColumnBody"); Element eStyle = buildStyle("lm"); Element eBContents = DocumentHelper.createElement("contents"); Element eBText = DocumentHelper.createElement("textItem"); Element eBSrc = DocumentHelper.createElement("dataSource"); Element eValue = DocumentHelper.createElement("dataItemValue"); eValue.addAttribute("refDataItem", p_sName); // Piece the Title together in the right order eTSrc.add(eLabel); eTText.add(eTSrc); eTContents.add(eTText); eTitle.add(eStyleTitle); eTitle.add(eTContents); // Piece the Body together eBSrc.add(eValue); eBText.add(eBSrc); eBContents.add(eBText); eBody.add(eStyle); eBody.add(eBContents); // Add the title and body to the column eCol.add(eTitle); eCol.add(eBody); if (position > 0) { n.content().add(position - 1, eCol); } else { n.add(eCol); } }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addListColumns() { Element n = (Element) oDocument .selectSingleNode("/report/layouts/layout/reportPages/page/pageBody/contents/list"); Element e = DocumentHelper.createElement("listColumns"); n.add(e); }
From source file:com.ikon.servlet.admin.StatsGraphServlet.java
License:Open Source License
/** * Convert a piechartdata to xml/* ww w . j a v a 2s. c om*/ * * @author puspendu.banerjee@gmail.com */ public String repoStatsXML(final String title, final DefaultPieDataset dataset) throws IOException, ServletException { Document document = DocumentHelper.createDocument(); Element root = document.addElement("RepoStats"); root.addElement("Title").addCDATA(title); Element dataSetElement = root.addElement("DataSet"); for (int i = 0; i < dataset.getItemCount(); i++) { Element itemElement = dataSetElement.addElement("Item"); itemElement.addElement("name").addCDATA(dataset.getKey(i).toString()); itemElement.addAttribute("percent", dataset.getValue(i).toString()); dataSetElement.add(itemElement); } return document.asXML(); }