List of usage examples for org.dom4j Element add
void add(Namespace namespace);
Namespace
to this element. From source file:com.zimbra.cs.fb.ExchangeMessage.java
License:Open Source License
public Document createRequest(FreeBusy fb) { Element root = DocumentHelper.createElement(EL_PROPERTYUPDATE); root.add(NS_XML); root.add(NS_MSFT);//from ww w . j a v a 2 s.c o m root.add(NS_WEB_FOLDERS); Element prop = root.addElement(EL_SET).addElement(EL_PROP); addElement(prop, PR_SUBJECT_A, PUBURL_SECOND_PART + getRcpt(LC.freebusy_exchange_cn2) + mCn); addElement(prop, PR_FREEBUSY_START_RANGE, minutesSinceMsEpoch(fb.getStartTime())); addElement(prop, PR_FREEBUSY_END_RANGE, minutesSinceMsEpoch(fb.getEndTime())); addElement(prop, PR_FREEBUSY_EMAIL_ADDRESS, mOu + getRcpt(LC.freebusy_exchange_cn3) + mCn); Element allMonths = addElement(prop, PR_FREEBUSY_ALL_MONTHS, null, ATTR_DT, MV_INT); Element allEvents = addElement(prop, PR_FREEBUSY_ALL_EVENTS, null, ATTR_DT, MV_BIN); Element busyMonths = addElement(prop, PR_FREEBUSY_BUSY_MONTHS, null, ATTR_DT, MV_INT); Element busyEvents = addElement(prop, PR_FREEBUSY_BUSY_EVENTS, null, ATTR_DT, MV_BIN); Element tentativeMonths = addElement(prop, PR_FREEBUSY_TENTATIVE_MONTHS, null, ATTR_DT, MV_INT); Element tentativeEvents = addElement(prop, PR_FREEBUSY_TENTATIVE_EVENTS, null, ATTR_DT, MV_BIN); Element oofMonths = addElement(prop, PR_FREEBUSY_OOF_MONTHS, null, ATTR_DT, MV_INT); Element oofEvents = addElement(prop, PR_FREEBUSY_OOF_EVENTS, null, ATTR_DT, MV_BIN); // XXX // some/all of these properties may not be necessary. // because we aren't sure about the purpose of these // properties, and the sample codes included them, // we'll just keep them in here. addElement(prop, PR_68410003, "0"); addElement(prop, PR_6842000B, "1"); addElement(prop, PR_6843000B, "1"); addElement(prop, PR_6846000B, "1"); addElement(prop, PR_684B000B, "1"); addElement(prop, PR_PROCESS_MEETING_REQUESTS, "0"); addElement(prop, PR_DECLINE_RECURRING_MEETING_REQUESTS, "0"); addElement(prop, PR_DECLINE_CONFLICTING_MEETING_REQUESTS, "0"); long startMonth, endMonth; startMonth = millisToMonths(fb.getStartTime()); endMonth = millisToMonths(fb.getEndTime()); IntervalList consolidated = new IntervalList(fb.getStartTime(), fb.getEndTime()); encodeIntervals(fb, startMonth, endMonth, IcalXmlStrMap.FBTYPE_BUSY, busyMonths, busyEvents, consolidated); encodeIntervals(fb, startMonth, endMonth, IcalXmlStrMap.FBTYPE_BUSY_TENTATIVE, tentativeMonths, tentativeEvents, consolidated); encodeIntervals(fb, startMonth, endMonth, IcalXmlStrMap.FBTYPE_BUSY_UNAVAILABLE, oofMonths, oofEvents, consolidated); encodeIntervals(consolidated, startMonth, endMonth, IcalXmlStrMap.FBTYPE_BUSY, allMonths, allEvents, null); return new DefaultDocument(root); }
From source file:com.zimbra.soap.util.WsdlGenerator.java
License:Open Source License
public static Document makeWsdlDoc(List<WsdlInfoForNamespace> nsInfos, String serviceName, String targetNamespace) { Namespace nsSvc = new Namespace(svcPrefix, targetNamespace); final QName svcTypes = QName.get("types", nsWsdl); Document document = DocumentHelper.createDocument(); Map<WsdlServiceInfo, Element> bindElems = Maps.newTreeMap(); Map<WsdlServiceInfo, Element> portTypeElems = Maps.newTreeMap(); Element root = document.addElement(QName.get("definitions", nsWsdl)); root.add(nsSvc); for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { root.add(wsdlNsInfo.getXsdNamespace()); }/* ww w .j a v a 2 s . c o m*/ root.add(nsZimbra); root.add(nsSoap); root.add(nsXsd); root.add(nsWsdl); root.addAttribute("targetNamespace", targetNamespace); root.addAttribute("name", serviceName); addWsdlTypesElement(root, svcTypes, nsInfos); for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { WsdlServiceInfo svcInfo = wsdlNsInfo.getSvcInfo(); if (!portTypeElems.containsKey(svcInfo)) { // wsdl:definitions/wsdl:portType Element portTypeElem = DocumentHelper.createElement(portType); portTypeElem.addAttribute("name", svcInfo.getPortTypeName()); portTypeElems.put(svcInfo, portTypeElem); } if (!bindElems.containsKey(svcInfo)) { // wsdl:definitions/wsdl:binding Element bindingElem = DocumentHelper.createElement(wsdlBinding); bindingElem.addAttribute("name", svcInfo.getBindingName()); bindingElem.addAttribute("type", svcPrefix + ":" + svcInfo.getPortTypeName()); // wsdl:definitions/wsdl:binding/soap:binding Element soapBindElem = bindingElem.addElement(soapBinding); soapBindElem.addAttribute("transport", "http://schemas.xmlsoap.org/soap/http"); soapBindElem.addAttribute("style", "document"); bindElems.put(svcInfo, bindingElem); } } for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { WsdlServiceInfo svcInfo = wsdlNsInfo.getSvcInfo(); for (String requestName : wsdlNsInfo.getRequests()) { String rootName = requestName.substring(0, requestName.length() - 7); String responseName = rootName + "Response"; String reqOpName = requestName.substring(0, 1).toLowerCase() + requestName.substring(1); String reqMsgName = wsdlNsInfo.getTag() + requestName + "Message"; String respMsgName = wsdlNsInfo.getTag() + responseName + "Message"; addWsdlRequestAndResponseMessageElements(root, wsdlNsInfo, reqMsgName, respMsgName, requestName, responseName); addWsdlPortTypeOperationElements(portTypeElems.get(svcInfo), reqMsgName, respMsgName, reqOpName); addWsdlBindingOperationElements(bindElems.get(svcInfo), wsdlNsInfo, reqOpName, rootName); } } addWsdlSoapHdrContextMessageElement(root); for (Entry<WsdlServiceInfo, Element> entry : portTypeElems.entrySet()) { root.add(entry.getValue()); } for (Entry<WsdlServiceInfo, Element> entry : bindElems.entrySet()) { root.add(entry.getValue()); } Set<WsdlServiceInfo> svcSet = Sets.newHashSet(); for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { WsdlServiceInfo svcInfo = wsdlNsInfo.getSvcInfo(); if (!svcSet.contains(svcInfo)) { svcSet.add(svcInfo); addWsdlServiceElement(root, svcInfo); } } return document; }
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); rootElement.add(Namespaces.xsi);/* www .ja va 2 s .c om*/ 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.FoxmlBuilder.java
License:Open Source License
private void addXmlContent(Element content, Element dataStreamVersion) { Element xmlContent = dataStreamVersion.addElement(new QName("xmlContent", Namespaces.foxml)); xmlContent.add(content); }
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 ava2 s.com 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.PeriodicalBuilder.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);/*from w w w .ja v a 2 s.c om*/ 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.getValue()); Element rightsEl = dcRootEl.addElement("dc:rights"); rightsEl.addText("policy:" + Policy.PUBLIC.toString().toLowerCase()); updateDcLanguages(dcDoc); }
From source file:cz.muni.stanse.checker.CheckerError.java
License:GNU General Public License
public Element xmlDump() { Element result = DocumentFactory.getInstance().createElement("error"); result.addElement("short_desc").addText(getShortDesc()); result.addElement("full_desc").addText(getFullDesc()); result.addElement("importance").addText(Integer.toString(getImportance())); result.addElement("checker_name").addText(getCheckerName()); Element eTraces = result.addElement("traces").addText(getCheckerName()); for (final CheckerErrorTrace trace : getTraces()) eTraces.add(trace.xmlDump()); return result; }
From source file:cz.muni.stanse.checker.CheckerErrorTrace.java
License:GNU General Public License
public Element xmlDump() { Element result = DocumentFactory.getInstance().createElement("trace"); result.addElement("description").addText(getDescription()); Element locs = result.addElement("locations"); for (final CheckerErrorTraceLocation location : getLocations()) locs.add(location.xmlDump()); return result; }
From source file:cz.mzk.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); rootElement.add(Namespaces.xsi);// www.jav a2s . c o m 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().substring(0, 1) + getModel().getValue().substring(1).toLowerCase()); 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.mzk.editor.server.newObject.MonographBuilder.java
License:Open Source License
@SuppressWarnings("unchecked") 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);/*from 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.getValue()); Element rightsEl = dcRootEl.addElement("dc:rights"); rightsEl.addText("policy:" + getPolicy().toString().toLowerCase()); updateDcLanguages(dcDoc); }