List of usage examples for org.dom4j Element addText
Element addText(String text);
Text
node with the given text to this element. From source file:org.talend.camel.designer.CamelDesignerCoreService.java
License:Open Source License
private void addSpringContent(Item item, Element jobElement) { Element routeSpringElement = jobElement.addElement("RouteSpring"); routeSpringElement.addAttribute(QName.get("space", Namespace.XML_NAMESPACE), "preserve"); String springContent = ((CamelProcessItem) item).getSpringContent(); routeSpringElement.addText(springContent); }
From source file:org.unitime.banner.ant.MergeXml.java
License:Apache License
private void merge(Element target, Element source) { for (Iterator i = source.attributeIterator(); i.hasNext();) { Attribute attribute = (Attribute) i.next(); target.addAttribute(attribute.getName(), attribute.getValue()); }//from www . j a v a2s. c o m for (Iterator i = source.nodeIterator(); i.hasNext();) { Node node = (Node) i.next(); if (node instanceof Element) { Element element = (Element) node; if ("property".equals(element.getName())) { String name = element.attributeValue("name", "noname"); Element targetProperty = null; for (Iterator j = target.elementIterator("property"); j.hasNext();) { Element property = (Element) j.next(); if (name.equals(property.attributeValue("name"))) { targetProperty = property; break; } } if (targetProperty != null) { target.remove(targetProperty); } if (element.getText() != null && element.getText().trim().length() > 0) { target.addElement("property").addAttribute("name", name).setText(element.getText()); } } else { if (target.elements(element.getName()).size() == 1 && source.elements(element.getName()).size() == 1) merge(target.element(element.getName()), element); else merge(target.addElement(element.getName()), element); } } else if (node instanceof Comment) { Comment comment = (Comment) node; target.addComment(comment.getText()); } else if (node instanceof CDATA) { CDATA data = (CDATA) node; target.add((CDATA) data.clone()); } else if (node instanceof Text) { Text text = (Text) node; if (text.getText() != null && text.getText().trim().length() > 0) target.addText(text.getText()); } else if (node instanceof Namespace) { } else { log("Unknown node " + node); } } }
From source file:org.uorm.orm.mapping.XmlReader.java
License:Apache License
@Override public Element read(String itemname, ResultSet result, ResultSetMetaData rsmd) throws Exception { Element dataElement = DocumentHelper.createElement(itemname); int count = rsmd.getColumnCount(); for (int i = 1; i <= count; i++) { String columnName = rsmd.getColumnLabel(i); if (null == columnName || 0 == columnName.length()) { columnName = rsmd.getColumnName(i); }//from w w w.j a v a 2s. co m int columnType = rsmd.getColumnType(i); Element curElement = dataElement.addElement(columnName); String val = getValue(result, i, columnType); if (val != null) { curElement.addText(val); // if (count<=2) { // curElement.addAttribute("type", rsmd.getColumnTypeName(i)); // } } } return dataElement; }
From source file:org.vosao.business.impl.imex.PageExporterImpl.java
License:Open Source License
private void createPageDetailsXML(PageEntity page, Element pageElement) { pageElement.addAttribute("url", page.getFriendlyURL()); pageElement.addAttribute("title", packTitle(page)); pageElement.addAttribute("commentsEnabled", String.valueOf(page.isCommentsEnabled())); if (page.getPublishDate() != null) { pageElement.addAttribute("publishDate", DateUtil.dateTimeToString(page.getPublishDate())); }/*from www . j a v a2 s . c o m*/ if (page.getEndPublishDate() != null) { pageElement.addAttribute("endPublishDate", DateUtil.dateTimeToString(page.getEndPublishDate())); } TemplateEntity template = getDao().getTemplateDao().getById(page.getTemplate()); if (template != null) { pageElement.addAttribute("theme", template.getUrl()); } pageElement.addElement("version").setText(page.getVersion().toString()); pageElement.addElement("versionTitle").setText(page.getVersionTitle()); pageElement.addElement("state").setText(page.getState().name()); pageElement.addElement("createUserEmail").setText(page.getCreateUserEmail()); pageElement.addElement("modUserEmail").setText(page.getModUserEmail()); if (page.getCreateDate() != null) { pageElement.addElement("createDate").setText(DateUtil.dateTimeToString(page.getCreateDate())); } if (page.getModDate() != null) { pageElement.addElement("modDate").setText(DateUtil.dateTimeToString(page.getModDate())); } StructureEntity structure = getDao().getStructureDao().getById(page.getStructureId()); pageElement.addElement("structure").setText(structure == null ? "" : structure.getTitle()); StructureTemplateEntity structureTemplate = getDao().getStructureTemplateDao() .getById(page.getStructureTemplateId()); pageElement.addElement("structureTemplate") .setText(structureTemplate == null ? "" : structureTemplate.getName()); pageElement.addElement("pageType").setText(page.getPageType().name()); pageElement.addElement("sortIndex") .setText(page.getSortIndex() == null ? "0" : page.getSortIndex().toString()); pageElement.addElement("keywords").setText(XmlUtil.notNull(page.getKeywords())); pageElement.addElement("description").setText(XmlUtil.notNull(page.getDescription())); pageElement.addElement("headHtml").setText(XmlUtil.notNull(page.getHeadHtml())); pageElement.addElement("searchable").setText(String.valueOf(page.isSearchable())); pageElement.addElement("velocityProcessing").setText(String.valueOf(page.isVelocityProcessing())); pageElement.addElement("skipPostProcessing").setText(String.valueOf(page.isSkipPostProcessing())); pageElement.addElement("cached").setText(String.valueOf(page.isCached())); pageElement.addElement("contentType").setText(XmlUtil.notNull(page.getContentType())); pageElement.addElement("wikiProcessing").setText(String.valueOf(page.isWikiProcessing())); pageElement.addElement("enableCkeditor").setText(String.valueOf(page.isEnableCkeditor())); pageElement.addElement("attributes").setText(XmlUtil.notNull(page.getAttributes())); pageElement.addElement("restful").setText(String.valueOf(page.isRestful())); List<ContentEntity> contents = getDao().getPageDao().getContents(page.getId()); for (ContentEntity content : contents) { Element contentElement = pageElement.addElement("content"); contentElement.addAttribute("language", content.getLanguageCode()); contentElement.addText(content.getContent()); } }
From source file:org.waarp.gateway.kernel.HttpXmlDefinition.java
License:Open Source License
/** * Construct a new Element with value/* w w w . jav a2s. c om*/ * * @param name * @param value * @return the new Element */ private static final Element newElement(String name, String value) { Element node = new DefaultElement(name); if (value != null && value.length() > 0) { node.addText(value); } return node; }
From source file:org.waarp.openr66.configuration.AuthenticationFileBasedConfiguration.java
License:Open Source License
/** * Construct a new Element with value/*w ww .j av a2 s .c om*/ * * @param name * @param value * @return the new Element */ private static Element newElement(String name, String value) { Element node = new DefaultElement(name); node.addText(value); return node; }
From source file:org.waarp.openr66.configuration.RuleFileBasedConfiguration.java
License:Open Source License
/** * Construct a new Element with value/* w w w. j av a2 s .co m*/ * * @param name * @param value * @return the new Element */ private static final Element newElement(String name, String value) { Element node = new DefaultElement(name); node.addText(value); return node; }
From source file:org.waarp.openr66.database.data.DbTaskRunner.java
License:Open Source License
/** * Construct a new Element with value/*w ww . ja va 2 s .c o m*/ * * @param name * @param value * @return the new Element */ private static Element newElement(String name, String value) { Element node = new DefaultElement(name); if (value != null) { node.addText(value); } return node; }
From source file:org.withinsea.izayoi.cortile.template.html.grammar.attr.core.Output.java
License:Mozilla Public License
@Override @Priority(Priority.LOWER)//from www. j av a2 s . c o m public void processAttr(Attribute attr) throws CortileException { Element elem = attr.getParent(); String attrname = attr.getName(); String attrvalue = attr.getValue(); if (attrname.startsWith("attr.")) { String forAttrname = attrname.substring("attr.".length()); Attribute forAttr = elem.attribute(forAttrname); String escapedValue = attrvalue .replace("<%=", "<%=" + Output.class.getCanonicalName() + ".escapeAttrValue(") .replace("%>", ")%>"); if (forAttr == null) { elem.addAttribute(forAttrname, escapedValue); } else { forAttr.setValue(escapedValue); } } else { elem.clearContent(); elem.addText(attr.getValue()); } attr.detach(); }
From source file:org.xmlactions.mapping.bean_to_xml.Bean.java
License:Apache License
public Element processBean(BeanToXml map, Element parent, Object obj) { Element element = BeanToXmlUtils.addElement(parent, getPrefix(), getName()); boolean processed = false; for (MapperAttribute attribute : getAttributes()) { attribute.buildXml(map, element, obj); processed = true;//from w w w. j a va2 s.co m } for (MapperElement node : getElements()) { node.buildXml(map, element, obj); processed = true; } if (processed == false && obj != null) { element.addText((String) obj); } return element; }