List of usage examples for org.jdom2.output Format getPrettyFormat
public static Format getPrettyFormat()
From source file:org.yawlfoundation.yawl.util.JDOMUtil.java
License:Open Source License
/****************************************************************************/ public static String elementToString(Element e) { if (e == null) return null; XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); return out.outputString(e); }
From source file:org.yawlfoundation.yawl.util.JDOMUtil.java
License:Open Source License
/** saves a JDOM Document to a file */ public static void documentToFile(Document doc, String path) { try {//from w ww. j ava 2 s .c om FileOutputStream fos = new FileOutputStream(path); XMLOutputter xop = new XMLOutputter(Format.getPrettyFormat()); xop.output(doc, fos); fos.flush(); fos.close(); } catch (IOException ioe) { _log.error("IO Exception in saving Document to file, filepath = " + path, ioe); } }
From source file:org.yawlfoundation.yawl.worklet.support.WorkletRecord.java
License:Open Source License
/** saves a JDOM Document to a file */ protected void saveDocument(String fileName, Document doc) { try {//from w ww . j a v a 2 s . co m FileOutputStream fos = new FileOutputStream(fileName); XMLOutputter xop = new XMLOutputter(Format.getPrettyFormat()); xop.output(doc, fos); fos.flush(); fos.close(); } catch (IOException ioe) { _log.error("IO Exception in saving Document to file", ioe); } }
From source file:org.yawlfoundation.yawl.wsif.WSIFInvoker.java
License:Open Source License
public static HashMap invokeMethod(String wsdlLocation, String portName, String operationName, Element inputDataDoc, AuthenticationConfig authconfig) { System.out/*from w w w . ja v a 2 s . c o m*/ .println("XMLOutputter = " + new XMLOutputter(Format.getPrettyFormat()).outputString(inputDataDoc)); System.out.println("wsdl location = " + wsdlLocation); System.out.println("port name = " + portName); System.out.println("operation name = " + operationName); List<String> argsV = new ArrayList<String>(); for (Element element : inputDataDoc.getChildren()) { argsV.add(element.getText()); } String[] args = new String[argsV.size()]; argsV.toArray(args); return invokeMethod(wsdlLocation, operationName, null, null, portName, null, args, 0, authconfig); }
From source file:par5e.ModuleXML.java
public void outputXML(String xmlFilePath) { XMLOutputter xmlOutput = new XMLOutputter(); Format fgFormat = Format.getPrettyFormat(); fgFormat.setEncoding("ISO-8859-1"); /* EscapeStrategy strat = new EscapeStrategy() { @Override/*from w w w .j a va2s.c om*/ public boolean shouldEscape(char ch) { boolean escape = false; switch(ch) { } return escape; } }; fgFormat.setEscapeStrategy(strat); */xmlOutput.setFormat(fgFormat); try { xmlOutput.output(doc, new FileWriter(xmlFilePath)); // xmlOutput.output(doc, System.out); } catch (IOException ex) { Logger.getLogger(ModuleXML.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:parcelhub.utilities.ParcelXMLFileWriter.java
License:Open Source License
/** * Creates the XML file which stores our parcel information. *//*from ww w . j a v a 2s . c om*/ public void createXMLFile() { Element root = new Element("Parcels"); Document xmlDatabase = new Document(); for (int i = 0; i < parcels.size(); i++) { Parcel parcelObj = parcels.get(i); Element parcelXML = new Element("Parcel"); parcelXML.addContent(new Element("parcelID").addContent(parcelObj.getParcelID())); parcelXML.addContent(new Element("name").addContent(parcelObj.getNameReciever())); parcelXML.addContent(new Element("address").addContent(parcelObj.getAddress())); parcelXML.addContent(new Element("date").addContent(parcelObj.getDate())); parcelXML.addContent(new Element("city").addContent(parcelObj.getCity())); parcelXML.addContent(new Element("state").addContent(parcelObj.getState())); parcelXML.addContent(new Element("zip").addContent(parcelObj.getZip())); root.addContent(parcelXML); } xmlDatabase.setRootElement(root); XMLOutputter outter = new XMLOutputter(); outter.setFormat(Format.getPrettyFormat()); try { outter.output(xmlDatabase, new FileWriter(new File(fileName))); } catch (IOException ex) { Logger.getLogger(ParcelXMLFileWriter.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:parserXML.Parser.java
License:Open Source License
/** * @Brief Displays the result of the parsing *///w ww . ja v a 2s .c o m static void affiche() { try { XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); sortie.output(document, System.out); } catch (java.io.IOException e) { } }
From source file:parserXML.Parser.java
License:Open Source License
/** * @Brief Save the xml in the file give as parameter. * @Param fichier Name of the output file. *//*from www . j a v a 2 s . c om*/ static void enregistre(String fichier) { try { XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat()); sortie.output(document, new FileOutputStream(fichier)); } catch (java.io.IOException e) { } }
From source file:password.pwm.util.java.XmlUtil.java
License:Open Source License
public static void outputDocument(final Document document, final OutputStream outputStream) throws IOException { final Format format = Format.getPrettyFormat(); format.setEncoding(STORAGE_CHARSET.toString()); final XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(format);//from w ww .j ava 2s . c om Writer writer = null; try { writer = new OutputStreamWriter(outputStream, STORAGE_CHARSET); outputter.output(document, writer); } finally { if (writer != null) { writer.close(); } } }
From source file:per.sunmes.kfat.sys.FileUtil.java
public static void exportProject() { AnimationProjectInfo project = SysData.instance().getProject(); if (project == null) { return;/*from ww w. ja va2 s . c o m*/ } Document document = new Document(); Element rootElement = new Element("kfa"); document.addContent(rootElement); rootElement.setAttribute("name", project.name); for (AnimationInfo ai : project.animations) { Element aiElement = new Element("animation"); aiElement.setAttribute("name", ai.name); rootElement.addContent(aiElement); for (FrameInfo fi : ai.frames) { Element fiElement = new Element("frame"); fiElement.setAttribute("id", String.valueOf(fi.id)); aiElement.addContent(fiElement); for (ImagePartInfo ipi : fi.parts) { Element ipiElement = new Element("part"); ipiElement.setAttribute("img", ipi.imageName); ipiElement.setAttribute("x", String.valueOf(ipi.x)); ipiElement.setAttribute("y", String.valueOf(ipi.y)); ipiElement.setAttribute("flipx", String.valueOf(ipi.flipX)); ipiElement.setAttribute("flipy", String.valueOf(ipi.flipY)); fiElement.addContent(ipiElement); } for (Rectangle rect : fi.rectangles) { Element rectElement = new Element("rectangle"); rectElement.setAttribute("x", String.valueOf(rect.x)); rectElement.setAttribute("y", String.valueOf(rect.y)); rectElement.setAttribute("width", String.valueOf(rect.width)); rectElement.setAttribute("height", String.valueOf(rect.height)); fiElement.addContent(rectElement); } } } XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); String outFile = String.format("%s/out/%s.xml", project.projectDirectory, project.name); try { outputter.output(document, new FileOutputStream(outFile)); JOptionPane.showMessageDialog(null, String.format("[%s],?!", outFile)); } catch (IOException ex) { Logger.getLogger(FileUtil.class.getName()).log(Level.SEVERE, null, ex); } }