List of usage examples for org.dom4j Element add
void add(Namespace namespace);
Namespace
to this element. From source file:com.globalsight.terminology.importer.CsvReaderThread.java
License:Apache License
private void addTermDescripGrp(Element p_node, Element p_descrip) { p_node.add(p_descrip); }
From source file:com.globalsight.terminology.importer.CsvReaderThread.java
License:Apache License
private void addSourceGrp(Element p_node, Element p_source) { p_node.add(p_source); }
From source file:com.haulmont.cuba.core.sys.AbstractViewRepository.java
License:Apache License
protected void addFile(Element commonRootElem, String fileName) { if (readFileNames.contains(fileName)) return;//w w w. j a va 2 s . c o m log.debug("Deploying views config: " + fileName); readFileNames.add(fileName); InputStream stream = null; try { stream = resources.getResourceAsStream(fileName); if (stream == null) { throw new IllegalStateException("Resource is not found: " + fileName); } SAXReader reader = new SAXReader(); Document doc; try { doc = reader.read(new InputStreamReader(stream, StandardCharsets.UTF_8)); } catch (DocumentException e) { throw new RuntimeException("Unable to parse view file " + fileName, e); } Element rootElem = doc.getRootElement(); for (Element includeElem : Dom4j.elements(rootElem, "include")) { String incFile = includeElem.attributeValue("file"); if (!StringUtils.isBlank(incFile)) addFile(commonRootElem, incFile); } for (Element viewElem : Dom4j.elements(rootElem, "view")) { commonRootElem.add(viewElem.createCopy()); } } finally { IOUtils.closeQuietly(stream); } }
From source file:com.haulmont.cuba.core.sys.persistence.MappingFileCreator.java
License:Apache License
private Document createDocument(Map<Class<?>, List<Attr>> mappings) { Document doc = DocumentHelper.createDocument(); Element rootEl = doc.addElement("entity-mappings", XMLNS); Namespace xsi = new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); rootEl.add(xsi); rootEl.addAttribute(new QName("schemaLocation", xsi), SCHEMA_LOCATION); rootEl.addAttribute("version", PERSISTENCE_VER); for (Map.Entry<Class<?>, List<Attr>> entry : mappings.entrySet()) { if (entry.getKey().getAnnotation(MappedSuperclass.class) != null) { Element entityEl = rootEl.addElement("mapped-superclass", XMLNS); entityEl.addAttribute("class", entry.getKey().getName()); createAttributes(entry, entityEl); }//from ww w . j a va 2s . c o m } for (Map.Entry<Class<?>, List<Attr>> entry : mappings.entrySet()) { if (entry.getKey().getAnnotation(Entity.class) != null) { Element entityEl = rootEl.addElement("entity", XMLNS); entityEl.addAttribute("class", entry.getKey().getName()); entityEl.addAttribute("name", entry.getKey().getAnnotation(Entity.class).name()); createAttributes(entry, entityEl); } } for (Map.Entry<Class<?>, List<Attr>> entry : mappings.entrySet()) { if (entry.getKey().getAnnotation(Embeddable.class) != null) { Element entityEl = rootEl.addElement("embeddable", XMLNS); entityEl.addAttribute("class", entry.getKey().getName()); createAttributes(entry, entityEl); } } return doc; }
From source file:com.haulmont.cuba.restapi.XMLConverter2.java
License:Apache License
@Override @Nonnull/*from w w w. j a v a2s . c o m*/ public String processServiceMethodResult(Object result, Class resultType) throws Exception { Document document = DocumentHelper.createDocument(); Element resultEl = document.addElement("result"); if (result instanceof Entity) { Entity entity = (Entity) result; Document convertedEntity = _process(entity, null); resultEl.add(convertedEntity.getRootElement()); } else if (result instanceof Collection) { if (!checkCollectionItemTypes((Collection) result, Entity.class)) throw new IllegalArgumentException( "Items that are not instances of Entity class found in service method result"); ArrayList list = new ArrayList((Collection) result); MetaClass metaClass = null; if (!list.isEmpty()) metaClass = ((Entity) list.get(0)).getMetaClass(); Document processed = _process(list, metaClass, null); resultEl.add(processed.getRootElement()); } else { if (result != null && resultType != Void.TYPE) { Datatype datatype = getDatatype(resultType); resultEl.setText(datatype != null ? datatype.format(result) : result.toString()); } else { encodeNull(resultEl); } } return documentToString(document); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addLayout() { Element n = (Element) oDocument.selectSingleNode("/report/layouts"); if (n == null) { addLayouts();/*from ww w .ja v a 2 s.c om*/ n = (Element) oDocument.selectSingleNode("/report/layouts"); } Element e = DocumentHelper.createElement("layout"); n.add(e); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addReportPages() { Element n = (Element) oDocument.selectSingleNode("/report/layouts/layout"); if (n == null) { addLayout();//from w ww .j a va2s.c o m n = (Element) oDocument.selectSingleNode("/report/layouts/layout"); } Element e = DocumentHelper.createElement("reportPages"); n.add(e); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addPage(String p_sName) { Element n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages"); if (n == null) { addReportPages();//from w ww .ja va 2 s. c o m n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages"); } Element e = DocumentHelper.createElement("page"); Element eStyle = buildStyle("pg"); e.addAttribute("name", p_sName); e.add(eStyle); n.add(e); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addPageBody() { Element n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages/page"); if (n == null) { addPage("Page1"); n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages/page"); }/* w ww.ja v a 2s .c o m*/ Element e = DocumentHelper.createElement("pageBody"); Element eStyle = buildStyle("pb"); e.add(eStyle); n.add(e); }
From source file:com.ibm.cognos.API.java
License:Open Source License
public void addPageBodyContents() { Element n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages/page/pageBody"); if (n == null) { addPageBody();/*from w ww. j av a2 s. c o m*/ n = (Element) oDocument.selectSingleNode("/report/layouts/layout/reportPages/page/pageBody"); } Element e = DocumentHelper.createElement("contents"); n.add(e); }