本文整理了Java中com.sun.org.apache.xml.internal.serialize.OutputFormat.setIndenting()
方法的一些代码示例,展示了OutputFormat.setIndenting()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.setIndenting()
方法的具体详情如下:
包路径:com.sun.org.apache.xml.internal.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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri
/**
* Constructs a new output format with the proper method,
* document type identifiers and media type for the specified
* document, and with the specified encoding. If <tt>indent</tt>
* is true, the document will be pretty printed with the default
* indentation level and default line wrapping.
*
* @param doc The document to output
* @param encoding The specified encoding
* @param indenting True for pretty printing
* @see #setEncoding
* @see #setIndenting
* @see #whichMethod
*/
public OutputFormat( Document doc, String encoding, boolean indenting )
{
this( doc );
setEncoding( encoding );
setIndenting( indenting );
}
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
/**
* Constructs a new output format with the proper method,
* document type identifiers and media type for the specified
* document, and with the specified encoding. If <tt>indent</tt>
* is true, the document will be pretty printed with the default
* indentation level and default line wrapping.
*
* @param doc The document to output
* @param encoding The specified encoding
* @param indenting True for pretty printing
* @see #setEncoding
* @see #setIndenting
* @see #whichMethod
*/
public OutputFormat( Document doc, String encoding, boolean indenting )
{
this( doc );
setEncoding( encoding );
setIndenting( indenting );
}
代码示例来源:origin: testIT-LivingDoc/livingdoc-core
@Override
public void printTo(Writer out) throws IOException {
if (dom == null) {
return;
}
StringWriter sw = new StringWriter();
OutputFormat format = new OutputFormat(dom);
format.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(sw, format);
serializer.serialize(dom);
out.write(sw.toString());
out.flush();
}
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
/**
* Constructs a new output format with the default values for
* the specified method and encoding. If <tt>indent</tt>
* is true, the document will be pretty printed with the default
* indentation level and default line wrapping.
*
* @param method The specified output method
* @param encoding The specified encoding
* @param indenting True for pretty printing
* @see #setEncoding
* @see #setIndenting
* @see #setMethod
*/
public OutputFormat( String method, String encoding, boolean indenting )
{
setMethod( method );
setEncoding( encoding );
setIndenting( indenting );
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri
/**
* Constructs a new output format with the default values for
* the specified method and encoding. If <tt>indent</tt>
* is true, the document will be pretty printed with the default
* indentation level and default line wrapping.
*
* @param method The specified output method
* @param encoding The specified encoding
* @param indenting True for pretty printing
* @see #setEncoding
* @see #setIndenting
* @see #setMethod
*/
public OutputFormat( String method, String encoding, boolean indenting )
{
setMethod( method );
setEncoding( encoding );
setIndenting( indenting );
}
代码示例来源:origin: stackoverflow.com
OutputFormat of = new OutputFormat("XML","windows-1250",true);
of.setIndent(1);
of.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(fos,of);
ContentHandler hd = serializer.asContentHandler();
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
ser._format.setOmitComments((features & COMMENTS)==0);
ser._format.setOmitXMLDeclaration((features & XMLDECL) == 0);
ser._format.setIndenting((features & FORMAT_PRETTY_PRINT) != 0);
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri
ser._format.setOmitComments((features & COMMENTS)==0);
ser._format.setOmitXMLDeclaration((features & XMLDECL) == 0);
ser._format.setIndenting((features & FORMAT_PRETTY_PRINT) != 0);
代码示例来源:origin: iTransformers/netTransformer
public String format(String unformattedXml) throws IOException, ParserConfigurationException, SAXException {
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();
}
代码示例来源: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: tulskiy/musique
@Override
public void save(Writer writer) {
logger.fine("Saving configuration");
try {
OutputFormat format = new OutputFormat(createDocument());
format.setLineWidth(65);
format.setIndenting(true);
format.setIndent(2);
XMLSerializer serializer = new XMLSerializer(writer, format);
serializer.serialize(getDocument());
writer.close();
}
catch (ConfigurationException ce) {
logger.severe("Failed to save configuration: " + ce.getMessage());
}
catch (IOException ioe) {
logger.severe("Failed to save configuration: " + ioe.getMessage());
}
}
代码示例来源:origin: stackoverflow.com
final XMLSerializer serializer = new XMLSerializer(out, format);
format.setIndenting(true);
format.setLineWidth(120);
format.setIndent(2);
代码示例来源: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: 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 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: SAMLRaider/SAMLRaider
public String getString(Document document, boolean indenting, int indent) throws IOException{
OutputFormat format = new OutputFormat(document);
format.setLineWidth(200);
format.setIndenting(indenting);
format.setIndent(indent);
format.setPreserveEmptyAttributes(true);
format.setEncoding("UTF-8");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLSerializer serializer = new XMLSerializer(baos, format);
serializer.asDOMSerializer();
serializer.serialize(document);
return baos.toString("UTF-8");
}
代码示例来源:origin: gooddata/GoodData-CL
/**
* Dumps the SOAPMessage to String
*
* @param msg the SOAP message
* @return the String representation of the message
* @throws IOException IO issue
* @throws SOAPException SOAP issue
*/
public String dumpSoapMessage(SOAPMessage msg) throws IOException, SOAPException {
Document doc = msg.getSOAPBody().getOwnerDocument();
OutputFormat format = new OutputFormat(doc);
format.setLineWidth(65);
format.setIndenting(true);
format.setIndent(2);
StringWriter s = new StringWriter();
XMLSerializer serializer = new XMLSerializer(s, format);
serializer.serialize(doc);
return s.toString();
}
内容来源于网络,如有侵权,请联系作者删除!