List of usage examples for org.dom4j Element add
void add(Namespace namespace);
Namespace
to this element. From source file:com.thoughtworks.go.server.JUnitReportGenerator.java
License:Apache License
public static void main(String[] args) throws Exception { Document doc = new SAXReader().read(new FileInputStream(new File("/home/cruise/sample_junit.xml"))); Element suite = (Element) doc.selectSingleNode("//testsuite"); Element rootElement = doc.getRootElement(); for (int i = 0; i < 50000; i++) { Element copy = suite.createCopy(); setAttr(i, copy, "name"); setAttr(i, copy, "hostname"); List<Element> elements = copy.selectNodes(".//testcase"); for (Element element : elements) { setAttr(i, element, "classname"); setAttr(i, element, "name"); }/*from w w w . j a va 2s .c o m*/ rootElement.add(copy); } FileUtils.writeStringToFile(new File("/tmp/repo/imagine.xml"), doc.asXML(), UTF_8); }
From source file:com.vmware.o11n.plugin.powershell.remote.impl.winrm.ClientState.java
License:Open Source License
private Document getRequestDocument(Action action, ResourceURI resourceURI, OptionSet optionSet, String shelId, Element bodyContent) {// www . j a v a2s . c o m Document doc = DocumentHelper.createDocument(); final Element envelope = doc.addElement(QName.get("Envelope", Namespaces.NS_SOAP_ENV)); envelope.add(getHeader(action, resourceURI, optionSet, shelId)); final Element body = envelope.addElement(QName.get("Body", Namespaces.NS_SOAP_ENV)); if (bodyContent != null) body.add(bodyContent); return doc; }
From source file:com.vmware.o11n.plugin.powershell.remote.impl.winrm.ClientState.java
License:Open Source License
private Element getHeader(Action action, ResourceURI resourceURI, OptionSet optionSet, String shellId) { final Element header = DocumentHelper.createElement(QName.get("Header", Namespaces.NS_SOAP_ENV)); header.addElement(QName.get("To", Namespaces.NS_ADDRESSING)).addText(targetURL.toString()); final Element replyTo = header.addElement(QName.get("ReplyTo", Namespaces.NS_ADDRESSING)); replyTo.addElement(QName.get("Address", Namespaces.NS_ADDRESSING)).addAttribute("mustUnderstand", "true") .addText("http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous"); header.addElement(QName.get("MaxEnvelopeSize", Namespaces.NS_WSMAN_DMTF)) .addAttribute("mustUnderstand", "true").addText("" + envelopSize); header.addElement(QName.get("MessageID", Namespaces.NS_ADDRESSING)).addText(getUUID()); header.addElement(QName.get("Locale", Namespaces.NS_WSMAN_DMTF)).addAttribute("mustUnderstand", "false") .addAttribute("xml:lang", locale); header.addElement(QName.get("DataLocale", Namespaces.NS_WSMAN_MSFT)).addAttribute("mustUnderstand", "false") .addAttribute("xml:lang", locale); header.addElement(QName.get("OperationTimeout", Namespaces.NS_WSMAN_DMTF)).addText(timeout); header.add(action.getElement()); if (shellId != null) { header.addElement(QName.get("SelectorSet", Namespaces.NS_WSMAN_DMTF)) .addElement(QName.get("Selector", Namespaces.NS_WSMAN_DMTF)).addAttribute("Name", "ShellId") .addText(shellId);//from w w w .jav a 2 s .c o m } header.add(resourceURI.getElement()); if (optionSet != null) { header.add(optionSet.getElement()); } return header; }
From source file:com.webarch.common.io.xml.XMLDao.java
License:Apache License
public XMLDao addElements(final String xPath, final List<Element> elements) { super.addModifier(xPath, new ElementModifier() { @Override// ww w . j a va 2s . c om public Element modifyElement(Element element) throws Exception { for (final Element childElement : elements) { element.add(childElement); } return element; } }); return this; }
From source file:com.webarch.common.io.xml.XMLDao.java
License:Apache License
@Override public XMLDao addElement(final String xPath, final Element subElement) { super.addModifier(xPath, new ElementModifier() { @Override//ww w.j av a 2 s.c o m public Element modifyElement(Element element) throws Exception { element.add(subElement); return element; } }); return this; }
From source file:com.xebia.mojo.dashboard.DashboardMojo.java
License:Apache License
private void createProjectRow(Branch dashboardTable, final MavenProject subProject, int rowNum) throws MojoExecutionException { final Element tableRow = dashboardTable.addElement("tr"); String cssClass = (rowNum == 0) ? "a" : "b"; tableRow.addAttribute("class", cssClass); createProjectNameCell(subProject, tableRow); doWithReports(new ReportColumnCallback() { public void handleReportColumn(DashboardReport report, String col) throws MojoExecutionException { if (report.canExecute(subProject)) { Node node = report.getContent(subProject, col); if (node != null) { Node content = node.detach(); Element cell = createTableCell(tableRow, null); String href = report.getLinkLocation(); if (href != null) { createLink(cell, DashboardUtil.determineCompletePath(subProject) + href, content); } else { cell.add(content); }/*from w w w . j a v a2s. c o m*/ } else { createTableCell(tableRow, "-"); } } else { createTableCell(tableRow, "-"); } } }); }
From source file:com.xebia.mojo.dashboard.DashboardMojo.java
License:Apache License
private void createLink(Branch parent, String href, Node content) { Element link = parent.addElement("a"); link.add(content); link.addAttribute("href", href); }
From source file:com.xpn.xwiki.objects.BaseObject.java
License:Open Source License
/** * {@inheritDoc}// w w w. j a v a2 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("object"); // Add Class if (bclass != null) { // If the class has fields, add field information to XML Collection fields = bclass.getFieldList(); if (fields.size() > 0) { oel.add(bclass.toXML()); } } oel.add(exportProperty("name", getName())); oel.add(exportProperty("number", String.valueOf(getNumber()))); oel.add(exportProperty("className", getClassName())); oel.add(exportProperty("guid", getGuid())); // Iterate over values/properties sorted by field name so that the values are // exported to XML in a consistent order. Iterator it = getSortedIterator(); while (it.hasNext()) { Element pel = new DOMElement("property"); PropertyInterface bprop = (PropertyInterface) it.next(); String pname = bprop.getName(); if (pname != null && !pname.trim().equals("")) { pel.add(bprop.toXML()); oel.add(pel); } } return oel; }
From source file:com.xpn.xwiki.objects.classes.BaseClass.java
License:Open Source License
public Element toXML() { Element cel = new DOMElement("class"); Element el = new DOMElement("name"); el.addText((getName() == null) ? "" : getName()); cel.add(el); el = new DOMElement("customClass"); el.addText((getCustomClass() == null) ? "" : getCustomClass()); cel.add(el);/*from ww w . j a v a 2s.com*/ el = new DOMElement("customMapping"); el.addText((getCustomMapping() == null) ? "" : getCustomMapping()); cel.add(el); el = new DOMElement("defaultViewSheet"); el.addText((getDefaultViewSheet() == null) ? "" : getDefaultViewSheet()); cel.add(el); el = new DOMElement("defaultEditSheet"); el.addText((getDefaultEditSheet() == null) ? "" : getDefaultEditSheet()); cel.add(el); el = new DOMElement("defaultWeb"); el.addText((getDefaultWeb() == null) ? "" : getDefaultWeb()); cel.add(el); el = new DOMElement("nameField"); el.addText((getNameField() == null) ? "" : getNameField()); cel.add(el); el = new DOMElement("validationScript"); el.addText((getValidationScript() == null) ? "" : getValidationScript()); cel.add(el); // Iterate over values sorted by field name so that the values are // exported to XML in a consistent order. Iterator it = getSortedIterator(); while (it.hasNext()) { PropertyClass bprop = (PropertyClass) it.next(); cel.add(bprop.toXML()); } return cel; }
From source file:com.xpn.xwiki.objects.classes.PropertyClass.java
License:Open Source License
public Element toXML() { Element pel = new DOMElement(getName()); // Iterate over values sorted by field name so that the values are // exported to XML in a consistent order. Iterator it = getSortedIterator(); while (it.hasNext()) { BaseProperty bprop = (BaseProperty) it.next(); pel.add(bprop.toXML()); }//from www. j a va 2s. c o m Element el = new DOMElement("classType"); el.addText(getClassType()); pel.add(el); return pel; }