本文整理了Java中com.sun.org.apache.xml.internal.serialize.OutputFormat.setIndent()
方法的一些代码示例,展示了OutputFormat.setIndent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.setIndent()
方法的具体详情如下:
包路径:com.sun.org.apache.xml.internal.serialize.OutputFormat
类名称:OutputFormat
方法名:setIndent
[英]Sets the indentation. The document will not be indented if the indentation is set to zero. Calling #setIndenting will reset this value to zero (off) or the default (on).
[中]设置缩进。如果缩进设置为零,文档将不会缩进。调用#setIndenting会将该值重置为零(off)或默认值(on)。
代码示例来源: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 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;
}
代码示例来源: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: org.fcrepo/fcrepo-common
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;
}
代码示例来源: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: com.ibm.sbt/com.ibm.commons.xml
private XMLSerializer createXMLSerializer(Node node, Format fmt) {
if(fmt==null) {
fmt = Format.defaultFormat;
}
OutputFormat format = new OutputFormat(); //node.getOwnerDocument());
format.setIndent(fmt.indent);
format.setOmitXMLDeclaration(!fmt.xmlDecl);
format.setEncoding(fmt.encoding);
return new XMLSerializer(format);
}
代码示例来源: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 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;
}
代码示例来源: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: fcrepo3/fcrepo
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;
}
代码示例来源: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: org.fcrepo/fcrepo-common
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;
}
代码示例来源: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: fcrepo3/fcrepo
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;
}
代码示例来源: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();
}
代码示例来源:origin: org.fcrepo/fcrepo-common
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;
}
代码示例来源:origin: stackoverflow.com
format.setIndent(2);
代码示例来源:origin: org.fcrepo/fcrepo-common
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;
}
代码示例来源:origin: fcrepo3/fcrepo
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;
}
代码示例来源:origin: fcrepo3/fcrepo
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;
}
内容来源于网络,如有侵权,请联系作者删除!