List of usage examples for org.dom4j.io OutputFormat createPrettyPrint
public static OutputFormat createPrettyPrint()
From source file:org.hibernate.internal.util.xml.XMLHelper.java
License:LGPL
public static void dump(Element element) { try {// w ww . j av a 2s .c o m // try to "pretty print" it OutputFormat outFormat = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(System.out, outFormat); writer.write(element); writer.flush(); System.out.println(""); } catch (Throwable t) { // otherwise, just dump it System.out.println(element.asXML()); } }
From source file:org.hibernatespatial.pojo.MappingsGenerator.java
License:Open Source License
public void write(Writer writer) throws IOException { OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter xmlWriter = new XMLWriter(writer, format); xmlWriter.write(this.mappingDoc); xmlWriter.close();/* w w w . j a v a2 s .c om*/ }
From source file:org.hightides.annotations.util.SpringXMLUtil.java
License:Apache License
/** * Private helper to save XML document.//from www .ja v a 2 s .c o m * @param filename * @param doc * @param backup * @return */ private static boolean saveXMLDocument(String filename, Document doc, boolean backup) { // copy the target to backup folder if (backup) FileUtil.backupFile(filename); // overwrite the target OutputFormat format = OutputFormat.createPrettyPrint(); format.setExpandEmptyElements(false); format.setIndentSize(4); format.setNewLineAfterDeclaration(true); XMLWriter out; try { out = new XMLWriter(new FileWriter(filename), format); out.write(doc); out.flush(); out.close(); return true; } catch (IOException e) { _log.info("Failed to write to output filename [" + filename + "]", e); return false; } }
From source file:org.hudsonci.utils.team.TeamManager.java
License:Open Source License
public void writeTeamsXml(File file) throws IOException { Document outDoc = DocumentHelper.createDocument(); Element root = outDoc.addElement("teamManager"); for (String admin : sysAdmins) { Team.addTextElement(root, "sysAdmin", admin); }//from www . ja v a2s .c o m for (Team team : teamMap.values()) { Element teamElement = root.addElement("team"); team.write(teamElement); } OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(new FileWriter(file), format); try { writer.write(outDoc); } finally { writer.close(); } }
From source file:org.infoglue.cms.applications.common.actions.SimpleXmlServiceAction.java
License:Open Source License
protected String getFormattedDocument(Document doc, boolean compact, boolean supressDecl) { OutputFormat format = compact ? OutputFormat.createCompactFormat() : OutputFormat.createPrettyPrint(); format.setSuppressDeclaration(supressDecl); format.setEncoding(ENCODING);/*from w w w. ja v a 2 s . c om*/ format.setExpandEmptyElements(false); StringWriter stringWriter = new StringWriter(); XMLWriter writer = new XMLWriter(stringWriter, format); try { writer.write(doc); } catch (IOException e) { e.printStackTrace(); } return stringWriter.toString(); }
From source file:org.infoglue.cms.applications.contenttool.actions.ContentTreeXMLAction.java
License:Open Source License
private String getFormattedDocument(Document doc, boolean compact) { OutputFormat format = compact ? OutputFormat.createCompactFormat() : OutputFormat.createPrettyPrint(); // format.setEncoding("iso-8859-1"); format.setEncoding("UTF-8"); format.setExpandEmptyElements(false); StringWriter stringWriter = new StringWriter(); XMLWriter writer = new XMLWriter(stringWriter, format); try {//from w ww .j a v a 2 s. c o m writer.write(doc); } catch (IOException e) { e.printStackTrace(); } return stringWriter.toString(); }
From source file:org.infoglue.cms.util.dom.DOMBuilder.java
License:Open Source License
/** * This method writes a document to file nicely. *//*ww w . j a va2s . co m*/ public void writePretty(Document document, String fileName) throws IOException { OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(new FileWriter(fileName), format); writer.write(document); writer.close(); }
From source file:org.infoglue.cms.util.dom.DOMBuilder.java
License:Open Source License
/** * This method writes a document to System.out. *//*from w w w.j a va 2 s. c o m*/ public void writeDebug(Document document) throws Exception { OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(System.out, format); writer.write(document); }
From source file:org.infoglue.cms.util.dom.DOMBuilder.java
License:Open Source License
/** * This method writes a element to System.out. *//*from w w w . j a va 2 s. c om*/ public void writeDebug(Element element) throws Exception { OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(System.out, format); writer.write(element); }
From source file:org.infoglue.cms.util.dom.DOMBuilder.java
License:Open Source License
public String getFormattedDocument(Document doc, boolean compact, boolean supressDecl, String encoding) { OutputFormat format = compact ? OutputFormat.createCompactFormat() : OutputFormat.createPrettyPrint(); format.setSuppressDeclaration(supressDecl); format.setEncoding(encoding);/* ww w .j a v a 2 s . com*/ format.setExpandEmptyElements(false); StringWriter stringWriter = new StringWriter(); XMLWriter writer = new XMLWriter(stringWriter, format); try { writer.write(doc); } catch (IOException e) { e.printStackTrace(); } return stringWriter.toString(); }