List of usage examples for org.dom4j Document addElement
Element addElement(String name);
Element
node with the given name to this branch and returns a reference to the new node. 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);//from w w w . j a v a 2s. co m for (WsdlInfoForNamespace wsdlNsInfo : nsInfos) { root.add(wsdlNsInfo.getXsdNamespace()); } 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:condorclient.utilities.XMLHandler.java
public String createName_IdXML() { String strXML = null;// w w w. ja v a 2 s . c o m Document document = DocumentHelper.createDocument(); // document. Element root = document.addElement("root"); Element info = root.addElement("info"); Element job = info.addElement("job"); job.addAttribute("name", "test"); job.addAttribute("id", "0"); 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("niInfo.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:condorclient.utilities.XMLHandler.java
public String createXML() { String strXML = null;/*from w ww .j a va2s .c o 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:controler.ExportDataToXML.java
public ExportDataToXML() throws UnsupportedEncodingException, IOException { ArrayList<Password> data = ApplicationData.getPasswords(); Document document = DocumentHelper.createDocument(); Element root = document.addElement("Registos"); Element registo;//from w w w . ja va 2 s .c o m int ord = 0; for (Password reg : data) { ord++; registo = root.addElement("Registo").addAttribute("num", "" + ord); registo.addElement("titulo").addText(reg.getTitle()); registo.addElement("user").addText(reg.getUser()); registo.addElement("pass").addText(reg.getPass()); registo.addElement("site").addText(reg.getSite()); registo.addElement("nota").addText(reg.getNote()); } // Pretty print the document to System.out OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer; writer = new XMLWriter(System.out, format); writer.write(document); //write to file FileOutputStream fos = new FileOutputStream("cyphDados.xml"); writer = new XMLWriter(fos, format); writer.write(document); //fos.close(); }
From source file:controllers.FXMLScicumulusController.java
public void createScicumulusXML() throws IOException, Exception { paneGraph.requestFocus();//Altera o foco para o paneGraph this.fieldsRequired = Arrays.asList(txtTagWorkflow, txtDescriptionWorkflow, txtExecTagWorkflow, txtExpDirWorkflow, txtNameDatabase, txtServerDatabase, txtPortDatabase, txtUsernameDatabase, txtPasswordDatabase, txt_server_directory); //Monta o arquivo Scicumulus.xml // if (!isFieldEmpty()) { //Cria o diretrio de expanso this.directoryExp = dirProject.getAbsolutePath() + "/" + txtExpDirWorkflow.getText().trim(); File dir = new File(this.directoryExp); dir.mkdirs();/*from w w w . j av a 2s .c om*/ File dirPrograms = new File(this.directoryExp + "/programs"); // this.directoryPrograms = dirPrograms.getPath(); dirPrograms.mkdir(); setDataActivity(this.activity);//Utilizado para gravar a ltima activity Document doc = DocumentFactory.getInstance().createDocument(); Element root = doc.addElement("SciCumulus"); Element environment = root.addElement("environment"); environment.addAttribute("type", "LOCAL"); Element binary = root.addElement("binary"); binary.addAttribute("directory", this.directoryExp + "/bin"); binary.addAttribute("execution_version", "SCCore.jar"); Element constraint = root.addElement("constraint"); constraint.addAttribute("workflow_exectag", "montage-1"); constraint.addAttribute("cores", this.txt_cores_machines.getText()); Element workspace = root.addElement("workspace"); workspace.addAttribute("workflow_dir", this.dirProject.getAbsolutePath()); Element database = root.addElement("database"); database.addAttribute("name", txtNameDatabase.getText()); database.addAttribute("server", txtServerDatabase.getText()); database.addAttribute("port", txtPortDatabase.getText()); database.addAttribute("username", txtUsernameDatabase.getText()); database.addAttribute("password", txtPasswordDatabase.getText()); Element hydraWorkflow = root.addElement("conceptualWorkflow"); hydraWorkflow.addAttribute("tag", txtTagWorkflow.getText().replace(" ", "").trim()); hydraWorkflow.addAttribute("description", txtDescriptionWorkflow.getText()); hydraWorkflow.addAttribute("exectag", txtExecTagWorkflow.getText()); hydraWorkflow.addAttribute("expdir", this.directoryExp); Element hydraActivity; for (Activity act : this.activities) { hydraActivity = hydraWorkflow.addElement("activity"); hydraActivity.addAttribute("tag", act.getTag().replace(" ", "").trim()); hydraActivity.addAttribute("description", act.getDescription()); hydraActivity.addAttribute("type", act.getType()); hydraActivity.addAttribute("template", act.getTemplatedir()); hydraActivity.addAttribute("activation", act.getActivation()); hydraActivity.addAttribute("extractor", "./extractor.cmd"); dir = new File(this.directoryExp + "/template_" + act.getName()); dir.mkdirs(); //Criando arquivo experiment.cmd File fout = new File(dir.getPath() + "/" + "experiment.cmd"); FileOutputStream fos = new FileOutputStream(fout); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos)); for (String command : act.getCommands()) { bw.write("sleep " + chb_sleeptime.getValue().toString()); bw.newLine(); bw.write(command); bw.newLine(); } bw.close(); String input = new String(); String output = new String(); int cont = 0; for (Relation rel : this.relations) { if (act.equals(rel.nodeStart)) { if (cont == 0) { //Primeira entrada Element relation1 = hydraActivity.addElement("relation"); relation1.addAttribute("reltype", "Input"); relation1.addAttribute("name", "I" + act.getName()); // relation1.addAttribute("filename", act.getInput_filename());//Colocar o nome do arquivo } Element relation2 = hydraActivity.addElement("relation"); relation2.addAttribute("reltype", "Output"); relation2.addAttribute("name", "O" + act.getName()); // relation2.addAttribute("filename", act.getOutput_filename());//Colocar o nome do arquivo // input = "I"+act.getName(); } if (act.equals(rel.nodeEnd)) { Activity dependency = (Activity) rel.nodeStart; Element relation1 = hydraActivity.addElement("relation"); relation1.addAttribute("reltype", "Input"); relation1.addAttribute("name", "I" + act.getName()); relation1.addAttribute("filename", act.getInput_filename());//Colocar o nome do arquivo relation1.addAttribute("dependency", dependency.getTag());//Colocar o nome da dependncia se existir if (cont == this.relations.size() - 1) { //ltima sada Element relation2 = hydraActivity.addElement("relation"); relation2.addAttribute("reltype", "Output"); relation2.addAttribute("name", "O" + act.getName()); // relation2.addAttribute("filename", act.getOutput_filename());//Colocar o nome do arquivo } // output = "O"+act.getName(); } cont++; } input = "I" + act.getName(); output = "O" + act.getName(); for (Field fieldAct : act.getFields()) { Element field = hydraActivity.addElement("field"); field.addAttribute("name", fieldAct.getName()); field.addAttribute("type", fieldAct.getType()); field.addAttribute("input", input); if (!fieldAct.getType().equals("string")) { field.addAttribute("output", output); } if (fieldAct.getType().equals("float")) { field.addAttribute("decimalplaces", fieldAct.getDecimalPlaces()); } if (fieldAct.getType().equals("file")) { field.addAttribute("operation", fieldAct.getOperation()); } } // String input = new String(); // String output = new String(); // // int cont = 0; // for (Relation rel : this.relations) { // if (act.equals(rel.nodeStart)) { // if (cont == 0) { // //Primeira entrada // Element relation1 = hydraActivity.addElement("relation"); // relation1.addAttribute("reltype", "Input"); // relation1.addAttribute("name", rel.getName() + "_" + "input"); //// relation1.addAttribute("filename", act.getInput_filename());//Colocar o nome do arquivo // } // Element relation2 = hydraActivity.addElement("relation"); // relation2.addAttribute("reltype", "Output"); // relation2.addAttribute("name", rel.getName() + "_" + "output"); //// relation2.addAttribute("filename", act.getOutput_filename());//Colocar o nome do arquivo // // input = rel.getName(); // } // if (act.equals(rel.nodeEnd)) { // Activity dependency = (Activity) rel.nodeStart; // Element relation1 = hydraActivity.addElement("relation"); // relation1.addAttribute("reltype", "Input"); // relation1.addAttribute("name", rel.getName() + "_" + "input"); // relation1.addAttribute("filename", act.getInput_filename());//Colocar o nome do arquivo // relation1.addAttribute("dependency", dependency.getTag());//Colocar o nome da dependncia se existir // // if (cont == this.relations.size() - 1) { // //ltima sada // Element relation2 = hydraActivity.addElement("relation"); // relation2.addAttribute("reltype", "Output"); // relation2.addAttribute("name", rel.getName() + "_" + "output"); //// relation2.addAttribute("filename", act.getOutput_filename());//Colocar o nome do arquivo // } // output = rel.getName(); // } // cont++; // } // Element field = hydraActivity.addElement("field"); // field.addAttribute("name", "FASTA_FILE"); // field.addAttribute("type", "string"); // field.addAttribute("input", input); // field.addAttribute("output", output); Element file = hydraActivity.addElement("File"); file.addAttribute("filename", "experiment.cmd"); file.addAttribute("instrumented", "true"); } Element executionWorkflow = root.addElement("executionWorkflow"); executionWorkflow.addAttribute("tag", txtTagWorkflow.getText().replace(" ", "").trim()); executionWorkflow.addAttribute("execmodel", "DYN_FAF"); executionWorkflow.addAttribute("expdir", this.directoryExp); executionWorkflow.addAttribute("max_failure", "1"); executionWorkflow.addAttribute("user_interaction", "false"); executionWorkflow.addAttribute("redundancy", "false"); executionWorkflow.addAttribute("reliability", "0.1"); Element relationInput = executionWorkflow.addElement("relation"); // relationInput.addAttribute("name", "IListFits"); relationInput.addAttribute("name", "input_workflow"); relationInput.addAttribute("filename", this.inputFile.getName()); //Gravando arquivo FileOutputStream fos = new FileOutputStream(this.directoryExp + "/SciCumulus.xml"); OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(fos, format); writer.write(doc); writer.flush(); try { //Criando o arquivo machines.conf createMachinesConf(); //Criando o arquivo parameter.txt // createParameterTxt(ta_parameters.getText()); } catch (IOException ex) { Logger.getLogger(FXMLScicumulusController.class.getName()).log(Level.SEVERE, null, ex); } //Copiando arquivos para o diretrio programs Utils.copyFiles(this.dirPrograms, directoryExp + "/programs/"); Utils.copyFiles(this.inputFile, directoryExp + "/" + this.inputFile.getName()); // sendWorkflow(this.directoryExp, "/deploy/experiments"); // sendWorkflow(this.directoryExp, this.txt_server_directory.getText().trim()); // String[] dirComplete = this.directoryExp.split(this.directoryDefaultFiles)[1].split("/"); // String dirLocal = this.directoryDefaultFiles + dirComplete[0]; // sendWorkflow(dirLocal, this.txt_server_directory.getText().trim()); sendWorkflow(this.dirProject.getAbsolutePath(), this.txt_server_directory.getText().trim()); // }else{ // JOptionPane.showMessageDialog(null, "Preencha os campos obrigatrios!"); // } // if (isActivityEmpty()) { // Dialogs.create() // .owner(null) // .title("Activity Duplicate") // .masthead(null) // .message("Existe uma activity que no est conectada!") // .showInformation(); // } }
From source file:controllers.FXMLScicumulusController.java
private void saveProject(String file) throws FileNotFoundException, UnsupportedEncodingException, IOException { Document doc = DocumentFactory.getInstance().createDocument(); Element root = doc.addElement("SciCumulus"); root.addAttribute("nameProject", txt_name_workflow.getText().trim()); Element activities = root.addElement("activities"); activities.addAttribute("quant", Integer.toString(this.activities.size())); for (Activity act : this.activities) { Element activity = activities.addElement("activity"); activity.addAttribute("id", act.getIdObject()); activity.addAttribute("name", act.getName()); activity.addAttribute("login", act.getLogin()); activity.addAttribute("password", act.getPassword()); activity.addAttribute("tag", act.getTag()); activity.addAttribute("description", act.getDescription()); activity.addAttribute("type", act.getType()); activity.addAttribute("templatedir", act.getTemplatedir()); activity.addAttribute("activation", act.getActivation()); activity.addAttribute("input_filename", act.getInput_filename()); activity.addAttribute("output_filename", act.getOutput_filename()); activity.addAttribute("timeCommand", act.getTimeCommand().toString()); // activity.addAttribute("commands", act.getCommands().toString()); for (Field field : act.getFields()) { Element fields = activity.addElement("fields"); fields.addAttribute("name", field.getName()); fields.addAttribute("type", field.getType()); fields.addAttribute("operation", field.getOperation()); fields.addAttribute("decimalPlaces", field.getDecimalPlaces()); fields.addAttribute("input", field.getInput()); fields.addAttribute("output", field.getOutput()); }/*from w w w .j a va2 s. co m*/ } Element relations = root.addElement("relations"); relations.addAttribute("quant", Integer.toString(this.relations.size())); for (Relation rel : this.relations) { Element relation = relations.addElement("relation"); relation.addAttribute("id", rel.getIdObject()); Activity actStart = (Activity) rel.getNodeStart(); Activity actEnd = (Activity) rel.getNodeEnd(); relation.addAttribute("name", rel.getName()); relation.addAttribute("idActStart", actStart.getIdObject()); relation.addAttribute("nameActStart", actStart.getName()); relation.addAttribute("idActEnd", actEnd.getIdObject()); relation.addAttribute("nameActEnd", actEnd.getName()); } //Gravando arquivo FileOutputStream fos = new FileOutputStream(file); OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(fos, format); writer.write(doc); writer.flush(); }
From source file:cz.dasnet.dasik.Dasik.java
License:Open Source License
@Override protected void onConnect() { log.info("Connected on " + getServer()); auth();/*from w w w .j ava 2 s . c o m*/ if (authed) { requestInvites(); } final Dasik bot = this; try { Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { bot.joinChannels(); } }, 1000); TimerTask dumpTask = new TimerTask() { @Override public void run() { Document document = DocumentHelper.createDocument(); Element channelinfo = document.addElement("channelinfo"); for (String c : activeChannels.keySet()) { Element channel = channelinfo.addElement("channel"); Element name = channel.addElement("name"); name.setText(c); Element size = channel.addElement("size"); size.setText("" + getUsers(c).length); } Element updatetime = channelinfo.addElement("updatetime"); updatetime.setText(new Long(new Date().getTime() / 1000).toString()); try { XMLWriter writer = new XMLWriter(new FileWriter("channelinfo.xml")); writer.write(document); writer.close(); } catch (IOException ex) { log.error("Unable to dump channel info", ex); } } }; Timer dump = new Timer("dump", true); dump.schedule(dumpTask, 10000, 60000); } catch (Exception ex) { this.joinChannels(); log.error("Channel autojoin timer failed to schedule the task.", ex); } }
From source file:de.ailis.xadrian.data.Complex.java
License:Open Source License
/** * Converts the complex into XML and returns it. * * @return The complex as XML/*from ww w . j a v a 2 s .com*/ */ public Document toXML() { final Document document = DocumentHelper.createDocument(); final Element root = document.addElement("complex"); root.addAttribute("version", "4"); root.addAttribute("game", this.game.getId()); root.addAttribute("suns", Integer.toString(getSuns().getPercent())); if (this.sector != null) root.addAttribute("sector", this.sector.getId()); root.addAttribute("addBaseComplex", Boolean.toString(this.addBaseComplex)); root.addAttribute("showingProductionStats", Boolean.toString(this.showingProductionStats)); root.addAttribute("showingShoppingList", Boolean.toString(this.showingShoppingList)); root.addAttribute("showingStorageCapacities", Boolean.toString(this.showingStorageCapacities)); root.addAttribute("showingComplexSetup", Boolean.toString(this.showingComplexSetup)); if (!this.factories.isEmpty()) { final Element factoriesE = root.addElement("complexFactories"); for (final ComplexFactory factory : this.factories) { final Element factoryE = factoriesE.addElement("complexFactory"); factoryE.addAttribute("factory", factory.getFactory().getId()); factoryE.addAttribute("disabled", Boolean.toString(factory.isDisabled())); if (factory.getFactory().isMine()) { final Element yieldsE = factoryE.addElement("yields"); for (final Integer yield : factory.getYields()) { final Element yieldE = yieldsE.addElement("yield"); yieldE.setText(Integer.toString(yield)); } } else { factoryE.addAttribute("quantity", Integer.toString(factory.getQuantity())); } } } if (!this.customPrices.isEmpty()) { final Element waresE = root.addElement("complexWares"); for (final Map.Entry<Ware, Integer> entry : this.customPrices.entrySet()) { final Ware ware = entry.getKey(); final int price = entry.getValue(); final Element wareE = waresE.addElement("complexWare"); wareE.addAttribute("ware", ware.getId()); wareE.addAttribute("use", Boolean.valueOf(price > 0).toString()); wareE.addAttribute("price", Integer.toString(Math.abs(price))); } } final Element shoppingListE = root.addElement("built"); shoppingListE.addAttribute("kits", Integer.toString(this.builtKits)); for (final Entry<String, Integer> entry : this.builtFactories.entrySet()) { final String id = entry.getKey(); final int quantity = entry.getValue(); final Element factoryE = shoppingListE.addElement("factory"); factoryE.addAttribute("id", id); factoryE.addAttribute("quantity", Integer.toString(quantity)); } return document; }
From source file:de.decoit.siemgui.service.converter.NeustaCorrelationRuleConverter.java
License:Open Source License
/** * Create a rule XML document from domain object information. * * @param description Rule description string * @param cond Rule condition object//w ww . j a va 2s . c o m * @param action Rule action object * @return Created XML document */ private Document createRuleXmlDocument(String description, CorrelationRuleCondition cond, CorrelationRuleAction action) { Document doc = DocumentHelper.createDocument(); Element eRule = doc.addElement("rule"); // Create the <rule><description>...</description></rule> block if (description != null) { eRule.addElement("description").addText(description); } // Create the <rule><condition><query>...</query></condition></rule> block if (cond.getQuery() != null) { eRule.addElement("condition").addElement("query").addText(cond.getQuery()); } // Create the <rule><action></action></rule> element Element eAction = eRule.addElement("action"); // Create the <rule><action><incidentname>...</incidentname></action></rule> block if (action.getIncidentName() != null) { eAction.addElement("incidentname").addText(action.getIncidentName()); } // Create the <rule><action><risk>...</risk></action></rule> block if (action.getRisk() != null) { eAction.addElement("risk").addText(action.getRisk()); } // Create the <rule><action><query>...</query></action></rule> blocks (multiple) action.getQuery().stream().forEach((q) -> { eAction.addElement("query").addText(q); }); // Create the <rule><action><updatequery>...</updatequery></action></rule> blocks (multiple) action.getUpdateQuery().stream().forEach((uq) -> { eAction.addElement("updatequery").addText(uq); }); // Create the <rule><action><recommendation>...</recommendation></action></rule> blocks (multiple) action.getRecommendation().stream().forEach((r) -> { eAction.addElement("recommendation").addText(r); }); // Create the <rule><action><explanation>...</explanation></action></rule> blocks (multiple) action.getExplanation().stream().forEach((e) -> { eAction.addElement("explanation").addText(e); }); return doc; }
From source file:de.innovationgate.utils.WGUtils.java
License:Apache License
/** * Creates a directory link file pointing to a target path * @param parentDir The directory to contain the link file * @param target The target path that the directory link should point to * @throws IOException//from w w w . j av a 2 s. co m */ public static void createDirLink(File parentDir, String target) throws IOException { File link = new File(parentDir, DIRLINK_FILE); Document doc = DocumentFactory.getInstance().createDocument(); Element dirlink = doc.addElement("dirlink"); Element path = dirlink.addElement("path"); path.addAttribute("location", target); XMLWriter writer = new XMLWriter(OutputFormat.createPrettyPrint()); writer.setOutputStream(new FileOutputStream(link)); writer.write(doc); writer.close(); }