} else { format = new OutputFormat("xml", null, prettyPrint); format.setLineWidth(0); // don't wrap lines
/** * Set the format line width value. * @param width line width value */ public void setLineWidth(int width) { format.setLineWidth(width); }
OutputStream outputStream = new FileOutputStream(new File(xMLFilePath)); OutputFormat outputFormat = new OutputFormat(doc, "UTF-8", true); outputFormat.setOmitComments(true); outputFormat.setLineWidth(0); XMLSerializer serializer = new XMLSerializer(outputStream, outputFormat); serializer.serialize(doc); outputStream.close();
/** * @deprecated relies on XMLSerializer which is a deprecated Xerces class, use domToString instead */ static public String prettyPrint(Element e) throws IOException { OutputFormat format = new OutputFormat(e.getOwnerDocument()); format.setLineWidth(65); format.setIndenting(true); format.setIndent(2); StringWriter out = new StringWriter(); XMLSerializer serializer = new XMLSerializer(out, format); serializer.serialize(e); return out.toString(); }
private static OutputFormat getXmlNoSpace(String encoding) { OutputFormat fmt = new OutputFormat("XML", encoding, false); // indent == 0 means add no indenting fmt.setIndent(0); // default line width is 72, but only applies when indenting fmt.setLineWidth(0); fmt.setPreserveSpace(false); return fmt; }
private static OutputFormat getXmlNoSpace(String encoding) { OutputFormat fmt = new OutputFormat("XML", encoding, false); // indent == 0 means add no indenting fmt.setIndent(0); // default line width is 72, but only applies when indenting fmt.setLineWidth(0); fmt.setPreserveSpace(false); return fmt; }
@Deprecated private static OutputFormat getOutputFormat(boolean omitXMLDeclaration, boolean omitDocumentType) { OutputFormat format = new OutputFormat(Method.XML, "UTF-8", true); format.setIndent(2); format.setLineWidth(80); if (omitXMLDeclaration) { format.setOmitXMLDeclaration(true); } if (omitDocumentType) { format.setOmitDocumentType(true); } return format; }
public static String format(String unformattedXml) throws IOException, ParserConfigurationException, SAXException { final Document document = parseXmlFile(unformattedXml); OutputFormat format = new OutputFormat(document); format.setLineWidth(LINE_WIDTH); format.setIndenting(true); format.setIndent(INDENT); Writer out = new StringWriter(); XMLSerializer serializer = new XMLSerializer(out, format); serializer.serialize(document); return out.toString(); }
public static String format(String unformattedXml) throws IOException, ParserConfigurationException, SAXException { final Document document = parseXmlFile(unformattedXml); OutputFormat format = new OutputFormat(document); format.setLineWidth(LINE_WIDTH); format.setIndenting(true); format.setIndent(INDENT); Writer out = new StringWriter(); XMLSerializer serializer = new XMLSerializer(out, format); serializer.serialize(document); return out.toString(); }
/** Get the output format to be used when serializing this buffer */ public OutputFormat getOutputFormat() { String xencoding = getIanaEncoding(getEncoding()); OutputFormat format = new OutputFormat(sourceDocument, xencoding, true); // do-indent==true format.setLineWidth(160); format.setIndent(4); format.setAllowJavaNames(true); return format; }
private static OutputFormat getMgmtWithDecl() { OutputFormat fmt = new OutputFormat("XML", "UTF-8", true); fmt.setIndent(2); fmt.setLineWidth(120); fmt.setPreserveSpace(false); fmt.setOmitXMLDeclaration(false); fmt.setOmitDocumentType(true); return fmt; }
private static OutputFormat getConsoleWithDocType() { OutputFormat fmt = new OutputFormat("XML", "UTF-8", true); fmt.setIndent(2); fmt.setLineWidth(80); fmt.setPreserveSpace(false); // default is false fmt.setOmitXMLDeclaration(false); // default is false fmt.setOmitDocumentType(false); return fmt; }
private static OutputFormat getConsoleWithDocType() { OutputFormat fmt = new OutputFormat("XML", "UTF-8", true); fmt.setIndent(2); fmt.setLineWidth(80); fmt.setPreserveSpace(false); // default is false fmt.setOmitXMLDeclaration(false); // default is false fmt.setOmitDocumentType(false); return fmt; }
private static OutputFormat getConsoleNoDocType() { OutputFormat fmt = new OutputFormat("XML", "UTF-8", true); fmt.setIndent(2); fmt.setLineWidth(80); fmt.setPreserveSpace(false); // default is false fmt.setOmitXMLDeclaration(false); fmt.setOmitDocumentType(true); return fmt; }
public static void writeXml(Element element, OutputStream os) throws IOException { OutputFormat format = new OutputFormat("XML", "UTF-8", false); format.setOmitComments(false); format.setLineWidth(0); XMLSerializer serializer = new XMLSerializer(format); serializer.setOutputByteStream(os); serializer.serialize(element); }
private static OutputFormat getMgmtNoDecl() { OutputFormat fmt = new OutputFormat("XML", "UTF-8", true); fmt.setIndent(2); fmt.setLineWidth(120); fmt.setPreserveSpace(false); fmt.setOmitXMLDeclaration(true); fmt.setOmitDocumentType(true); return fmt; }
private static OutputFormat getMgmtNoDecl() { OutputFormat fmt = new OutputFormat("XML", "UTF-8", true); fmt.setIndent(2); fmt.setLineWidth(120); fmt.setPreserveSpace(false); fmt.setOmitXMLDeclaration(true); fmt.setOmitDocumentType(true); return fmt; }
private static OutputFormat getMgmtWithDecl() { OutputFormat fmt = new OutputFormat("XML", "UTF-8", true); fmt.setIndent(2); fmt.setLineWidth(120); fmt.setPreserveSpace(false); fmt.setOmitXMLDeclaration(false); fmt.setOmitDocumentType(true); return fmt; }
private static OutputFormat getConsoleNoDocType() { OutputFormat fmt = new OutputFormat("XML", "UTF-8", true); fmt.setIndent(2); fmt.setLineWidth(80); fmt.setPreserveSpace(false); // default is false fmt.setOmitXMLDeclaration(false); fmt.setOmitDocumentType(true); return fmt; }
public SerializingUserLayoutDao() { layoutOutputFormat=new OutputFormat(); layoutOutputFormat.setIndenting(true); layoutOutputFormat.setLineWidth(0); layoutOutputFormat.setOmitDocumentType(false); layoutOutputFormat.setPreserveSpace(true); layoutOutputFormat.setEncoding("UTF-8"); layoutOutputFormat.setOmitComments(false); layoutOutputFormat.setOmitXMLDeclaration(false); layoutOutputFormat.setDoctype(publicDoctype, systemDoctype); }