org.apache.xml.serialize.OutputFormat.setIndent()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中org.apache.xml.serialize.OutputFormat.setIndent()方法的一些代码示例,展示了OutputFormat.setIndent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat.setIndent()方法的具体详情如下:
包路径:org.apache.xml.serialize.OutputFormat
类名称:OutputFormat
方法名:setIndent

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: graphhopper/jsprit

private OutputFormat createOutputFormat() {
  OutputFormat format = new OutputFormat();
  format.setIndenting(true);
  format.setIndent(5);
  return format;
}

代码示例来源:origin: org.objectweb.jonas/jonas-commons

/**
 * Set the format line indent value.
 * @param indent line indent value
 */
public void setIndent(int indent) {
  format.setIndent(indent);
}

代码示例来源: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.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: 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 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 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: 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.netbeans.modules/org-netbeans-modules-visualweb-insync

/** 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;
}

代码示例来源: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: 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: 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: 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: 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: 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;
}

代码示例来源: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: 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: 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: 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;
}

相关文章