本文整理了Java中org.apache.xml.serialize.OutputFormat.setIndenting()
方法的一些代码示例,展示了OutputFormat.setIndenting()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.setIndenting()
方法的具体详情如下:
包路径:org.apache.xml.serialize.OutputFormat
类名称:OutputFormat
方法名:setIndenting
[英]Sets the indentation on and off. When set on, the default indentation level and default line wrapping is used (see Defaults#Indent and Defaults#LineWidth). To specify a different indentation level or line wrapping, use #setIndent and #setLineWidth.
[中]打开和关闭缩进。设置为on时,将使用默认缩进级别和默认换行(请参见默认值#缩进和默认值#线宽)。要指定不同的缩进级别或换行,请使用#setIndent和#setLineWidth。
代码示例来源:origin: jersey/jersey
private static XMLSerializer getXMLSerializer(final OutputStream os, final String[] cdataElements)
throws InstantiationException,
IllegalAccessException, ClassNotFoundException {
// configure an OutputFormat to handle CDATA
final OutputFormat of = new OutputFormat();
// specify which of your elements you want to be handled as CDATA.
// The use of the '^' between the namespaceURI and the localname
// seems to be an implementation detail of the xerces code.
// When processing xml that doesn't use namespaces, simply omit the
// namespace prefix as shown in the third CDataElement below.
of.setCDataElements(cdataElements);
// set any other options you'd like
of.setPreserveSpace(true);
of.setIndenting(true);
// create the serializer
final XMLSerializer serializer = new XMLSerializer(of);
serializer.setOutputByteStream(os);
return serializer;
}
代码示例来源:origin: stackoverflow.com
OutputFormat format = new OutputFormat(document);
format.setIndenting(true);
format.setOmitXMLDeclaration(true);
代码示例来源:origin: graphhopper/jsprit
private OutputFormat createOutputFormat() {
OutputFormat format = new OutputFormat();
format.setIndenting(true);
format.setIndent(5);
return format;
}
代码示例来源:origin: org.geotools.xsd/gt-core
/**
* Sets the indentation on and off.
* <p>
* When set on, the default indentation level and default line wrapping is
* used (see {@link #getIndentSize()} and {@link #getLineWidth()}). To
* specify a different indentation level or line wrapping, use
* {@link #setIndent(int)} and {@link #setLineWidth(int)}).
* </p>
*
* @param doIndent
* <code>true</code> if indentation should be on
*/
public void setIndenting(final boolean doIndent) {
outputFormat.setIndenting(doIndent);
}
代码示例来源:origin: org.geotools/gt2-xml-xsd
/**
* Sets the indentation on and off.
* <p>
* When set on, the default indentation level and default line wrapping is
* used (see {@link #getIndentSize()} and {@link #getLineWidth()}). To
* specify a different indentation level or line wrapping, use
* {@link #setIndent(int)} and {@link #setLineWidth(int)}).
* </p>
*
* @param doIndent
* <code>true</code> if indentation should be on
*/
public void setIndenting(final boolean doIndent) {
outputFormat.setIndenting(doIndent);
}
代码示例来源:origin: stackoverflow.com
OutputFormat format = new OutputFormat(doc);
format.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(System.out, format);
serializer.serialize(doc);
代码示例来源:origin: org.wso2.bpel/ode-utils
/**
* @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();
}
代码示例来源:origin: com.axway.ats.framework/ats-core
public void save() throws AtsConfigurationException {
// save the XML file
try {
OutputFormat format = new OutputFormat(doc);
format.setIndenting(true);
format.setIndent(4);
format.setLineWidth(1000);
XMLSerializer serializer = new XMLSerializer(new FileOutputStream(new File(atsConfigurationFile)),
format);
serializer.serialize(doc);
} catch (Exception e) {
throw new AtsConfigurationException("Error saving ATS configuration in '" + atsConfigurationFile
+ "'", e);
}
}
代码示例来源:origin: org.jasig.portal/uportal3-impl
/**
* Gets the contents of an XML Document or Element as a nicely formatted string.
* This method is useful for debugging.
* @param node the Node to print; must be of type Document or Element
* @return a nicely formatted String suitable for printing
*/
public static String serializeNode(Node node) {
OutputFormat format = new OutputFormat();
format.setOmitXMLDeclaration(true);
format.setIndenting(true);
return serializeNode(node,format);
}
代码示例来源:origin: Quetzal-RDF/quetzal
default void printDocument(Document doc) throws Exception {
OutputFormat format = new OutputFormat(doc);
format.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(System.out, format);
serializer.serialize(doc);
}
代码示例来源:origin: br.com.jarch/jarch-util
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();
}
代码示例来源:origin: br.com.jarch/jarch-utils
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();
}
代码示例来源:origin: org.fcrepo/fcrepo-common
private static OutputFormat getPrettyPrint() {
OutputFormat fmt = new OutputFormat("XML", "UTF-8", true);
fmt.setEncoding("UTF-8");
fmt.setIndenting(true);
fmt.setIndent(2);
fmt.setOmitXMLDeclaration(true);
return fmt;
}
代码示例来源:origin: fcrepo3/fcrepo
private static OutputFormat getPrettyPrintWithDecl() {
OutputFormat fmt = new OutputFormat("XML", "UTF-8", true);
fmt.setEncoding("UTF-8");
fmt.setIndenting(true);
fmt.setIndent(2);
fmt.setOmitXMLDeclaration(false);
return fmt;
}
}
代码示例来源:origin: org.fcrepo/fcrepo-common
private static OutputFormat getPrettyPrintWithDecl() {
OutputFormat fmt = new OutputFormat("XML", "UTF-8", true);
fmt.setEncoding("UTF-8");
fmt.setIndenting(true);
fmt.setIndent(2);
fmt.setOmitXMLDeclaration(false);
return fmt;
}
}
代码示例来源:origin: fcrepo3/fcrepo
private static OutputFormat getPrettyPrint() {
OutputFormat fmt = new OutputFormat("XML", "UTF-8", true);
fmt.setEncoding("UTF-8");
fmt.setIndenting(true);
fmt.setIndent(2);
fmt.setOmitXMLDeclaration(true);
return fmt;
}
代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core
public static String formatXml(String unformattedXml) throws
ExecutionPlanConfigurationException {
try {
final Document document = parseXmlFile(unformattedXml);
OutputFormat format = new OutputFormat(document);
format.setLineWidth(65);
format.setIndenting(true);
format.setIndent(2);
Writer out = new StringWriter();
XMLSerializer serializer = new XMLSerializer(out, format);
serializer.serialize(document);
return out.toString();
} catch (IOException e) {
throw new ExecutionPlanConfigurationException(e);
}
}
代码示例来源:origin: org.opengis.cite/cite1-utils
public static void writeXml(Element element, Writer out, int indent)
throws IOException
{
OutputFormat format = new OutputFormat("XML", "UTF-8", false);
format.setOmitComments(false);
if (indent > 0) {
format.setIndenting(true);
format.setIndent(indent);
}
format.setLineWidth(0);
XMLSerializer serializer = new XMLSerializer(format);
serializer.setOutputCharStream(out);
serializer.serialize(element);
}
代码示例来源:origin: org.opengis.cite/cite1-utils
public static void writeXml(Document document, Writer out, int indent)
throws IOException
{
OutputFormat format = new OutputFormat("XML", "UTF-8", false);
format.setOmitComments(false);
if (indent > 0) {
format.setIndenting(true);
format.setIndent(indent);
}
format.setLineWidth(0);
XMLSerializer serializer = new XMLSerializer(format);
serializer.setOutputCharStream(out);
serializer.serialize(document);
}
代码示例来源:origin: org.jasig.portal/uportal3-impl
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);
}
内容来源于网络,如有侵权,请联系作者删除!