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:com.xpn.xwiki.stats.impl.XWikiStats.java
License:Open Source License
/** * {@inheritDoc}/*w ww . jav a 2 s .c o m*/ * * @see com.xpn.xwiki.objects.BaseCollection#toXML(com.xpn.xwiki.objects.classes.BaseClass) */ @Override public Element toXML(BaseClass bclass) { Element oel = new DOMElement(XMLNODE_OBJECT); // Add Class if (bclass != null) { if (bclass.getFieldList().size() > 0) { oel.add(bclass.toXML()); } } Element el = new DOMElement(XMLNODE_NAME); el.addText(getName()); oel.add(el); el = new DOMElement(XMLNODE_NUMBER); el.addText(getNumber() + ""); oel.add(el); el = new DOMElement(XMLNODE_CLASSNAME); el.addText(getClassName()); oel.add(el); for (Iterator<?> it = getFieldList().iterator(); it.hasNext();) { Element pel = new DOMElement(XMLNODE_PROPERTY); PropertyInterface bprop = (PropertyInterface) it.next(); pel.add(bprop.toXML()); oel.add(pel); } return oel; }
From source file:com.xpn.xwiki.tool.xar.XarMojo.java
License:Open Source License
/** * Add all the XML elements under the <info> element (name, description, license, author, version and whether * it's a backup pack or not)./*from ww w. j a v a 2 s .c o m*/ * * @param infoElement the info element to which to add to */ private void addInfoElements(Element infoElement) { Element el = new DOMElement("name"); el.addText(this.project.getName()); infoElement.add(el); el = new DOMElement("description"); String description = this.project.getDescription(); if (description == null) { el.addText(""); } else { el.addText(description); } infoElement.add(el); el = new DOMElement("licence"); el.addText(""); infoElement.add(el); el = new DOMElement("author"); el.addText("XWiki.Admin"); infoElement.add(el); el = new DOMElement("version"); el.addText(this.project.getVersion()); infoElement.add(el); el = new DOMElement("backupPack"); el.addText("true"); infoElement.add(el); }
From source file:com.zimbra.cs.client.soap.LmcCheckSpellingRequest.java
License:Open Source License
protected Element getRequestXML() { Element request = DocumentHelper.createElement(MailConstants.CHECK_SPELLING_REQUEST); request.addText(mText); return request; }
From source file:condorclient.utilities.XMLHandler.java
public String createXML() { String strXML = null;//from w ww.j a v a2 s . co m Document document = DocumentHelper.createDocument(); // document. Element root = document.addElement("root"); Element job = root.addElement("Job"); Element jobDescFile = job.addElement("item"); jobDescFile.addAttribute("about", "descfile"); Element file_name = jobDescFile.addElement("name"); file_name.addText("submit.txt"); Element filer_path = jobDescFile.addElement("path"); filer_path.addText("D:\\HTCondor\\test\\2"); StringWriter strWtr = new StringWriter(); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("UTF-8"); XMLWriter xmlWriter = new XMLWriter(strWtr, format); try { xmlWriter.write(document); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } strXML = strWtr.toString(); //-------- //------- //strXML=document.asXML(); //------ //------------- File file = new File("condorclient.xml"); if (file.exists()) { file.delete(); } try { file.createNewFile(); XMLWriter out = new XMLWriter(new FileWriter(file)); out.write(document); out.flush(); out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //-------------- return strXML; }
From source file:cz.fi.muni.xkremser.editor.server.newObject.FoxmlBuilder.java
License:Open Source License
protected void decorateDCStream() { Element rootElement = DocumentHelper.createElement(new QName("dc", Namespaces.oai_dc)); rootElement.add(Namespaces.dc);/*from w w w . j a va 2 s . com*/ rootElement.add(Namespaces.xsi); Element title = rootElement.addElement(new QName("title", Namespaces.dc)); title.addText(getLabel()); Element identifier = rootElement.addElement(new QName("identifier", Namespaces.dc)); identifier.setText(getPid()); Element type = rootElement.addElement(new QName("type", Namespaces.dc)); type.addText("model:" + getModel().getValue()); Element rights = rootElement.addElement(new QName("rights", Namespaces.dc)); rights.addText("policy:" + getPolicy().toString().toLowerCase()); appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.DC, rootElement, null, null); dcXmlContent = rootElement.getDocument(); }
From source file:cz.fi.muni.xkremser.editor.server.newObject.IntPartBuilder.java
License:Open Source License
/** * {@inheritDoc}/*from w w w. jav a2 s . c o m*/ */ @Override protected void decorateMODSStream() { String volumeLabel = getLabel(); Element modsCollection = FoxmlUtils.createModsCollectionEl(); Namespace modsNs = Namespaces.mods; Element mods = modsCollection.addElement(new QName("mods", modsNs)); mods.addAttribute("version", "3.3"); Element idUrn = mods.addElement(new QName("identifier", modsNs)); idUrn.addAttribute("type", "urn"); idUrn.addText(getUuid()); Element titleInfo = mods.addElement(new QName("titleInfo", modsNs)); Element title = titleInfo.addElement(new QName("title", modsNs)); title.addText(volumeLabel); Element typeOfResource = mods.addElement(new QName("typeOfResource", modsNs)); typeOfResource.addText("text"); Element part = mods.addElement(new QName("part", modsNs)); part.addAttribute("type", "Chapter"); Element extent = part.addElement(new QName("extent", modsNs)); extent.addAttribute("unit", "pages"); List<RelsExtRelation> children = getChildren(); Element start = extent.addElement(new QName("start", modsNs)); start.addText(children.get(0).getTargetName()); Element end = extent.addElement(new QName("end", modsNs)); end.addText(children.get(children.size() - 1).getTargetName()); Element total = extent.addElement(new QName("total", modsNs)); total.addText(String.valueOf(children.size())); // Element detail = part.addElement(new QName("detail", modsNs)); // detail.addAttribute("type", "pageNumber"); // Element number = detail.addElement(new QName("number", modsNs)); // number.addText(""); Element accessCondition = mods.addElement(new QName("accessCondition", modsNs)); accessCondition.addAttribute("type", "restrictionOnAccess"); appendDatastream(DATASTREAM_CONTROLGROUP.X, DATASTREAM_ID.BIBLIO_MODS, modsCollection, null, null); }
From source file:cz.fi.muni.xkremser.editor.server.newObject.MonographBuilder.java
License:Open Source License
private void updateDcDoc(Document dcDoc, String pid, String signature, String sysno, DigitalObjectModel model) { Element dcRootEl = dcDoc.getRootElement(); Attribute schemaLoc = dcRootEl.attribute("schemaLocation"); dcRootEl.remove(schemaLoc);//w w w . j a v a 2 s. co m Namespace xsi = DocumentHelper.createNamespace("xsi2", FedoraNamespaces.SCHEMA_NAMESPACE_URI); dcRootEl.add(xsi); dcRootEl.addAttribute(new QName("schemaLocation", xsi), "http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"); XPath typeXpath = Dom4jUtils.createXPath("/oai_dc:dc/dc:identifier"); List<? extends Node> nodes = typeXpath.selectNodes(dcDoc); for (Node node : nodes) { node.detach(); } Element idUuid = dcRootEl.addElement("dc:identifier"); idUuid.addText(pid); for (Node node : nodes) { if (node.getText() != null && !"".equals(node.getText().trim()) && !node.getText().contains(Constants.FEDORA_UUID_PREFIX)) { Element temp = dcRootEl.addElement("dc:identifier"); temp.addText(node.getText()); } } if (signature != null) { Element idSignature = dcRootEl.addElement("dc:identifier"); idSignature.addText("signature:" + signature); } if (sysno != null) { Element idSysno = dcRootEl.addElement("dc:identifier"); idSysno.addText("sysno:" + sysno); } removeDcTypeElements(dcDoc); Element typeEl = dcRootEl.addElement("dc:type"); typeEl.addText("model:" + model.toString()); Element rightsEl = dcRootEl.addElement("dc:rights"); rightsEl.addText("policy:" + Policy.PUBLIC.toString().toLowerCase()); updateDcLanguages(dcDoc); }
From source file:cz.fi.muni.xkremser.editor.server.newObject.MonographBuilder.java
License:Open Source License
private void updateLanguages(Document doc, XPath xpath) { List<? extends Node> nodes = xpath.selectNodes(doc); for (Node languageNode : nodes) { Element languageEl = (Element) languageNode; String originalLang = languageEl.getTextTrim(); languageEl.clearContent();//from w ww . ja v a 2s .c o m languageEl.addText(transformLanguage(originalLang)); } }
From source file:cz.fi.muni.xkremser.editor.server.newObject.MonographBuilder.java
License:Open Source License
private void addPhysicalLocation(Document modsDoc, MarcSpecificMetadata marc) { String location = marc.getLocation(); if (location != null) { Element locationEl = (Element) locationXpath.selectSingleNode(modsDoc); Element shelfLocatorEl = (Element) shelfLocatorXpath.selectSingleNode(locationEl); String shelfLocatorStr = shelfLocatorEl.getTextTrim(); shelfLocatorEl.detach();/* w w w . ja v a 2 s . c o m*/ Element physicalLocationEl = locationEl.addElement(new QName("physicalLocation", Namespaces.mods)); physicalLocationEl.addText(location); shelfLocatorEl = locationEl.addElement(new QName("shelfLocator", Namespaces.mods)); shelfLocatorEl.addText(shelfLocatorStr); } }
From source file:cz.fi.muni.xkremser.editor.server.newObject.MonographBuilder.java
License:Open Source License
private void addUdcOrDdc(Document modsDoc, MarcSpecificMetadata marc) { if (marc.getUdcs() == null) { return;/*from ww w . j a va 2 s. c o m*/ } List<String> udcs = marc.getUdcs(); for (String udc : udcs) { Element modsEl = (Element) modsXpath.selectSingleNode(modsDoc); Element classificationEl = modsEl.addElement(new QName("classification", Namespaces.mods)); classificationEl.addAttribute("authority", "udc"); classificationEl.addText(udc); } }