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

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

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

OutputFormat.setLineSeparator介绍

[英]Sets the line separator. The default is the Web line separator (\n). The machine's line separator can be obtained from the system property line.separator, but is only useful if the document is edited on machines of the same type. For general documents, use the Web line separator.
[中]设置行分隔符。默认值为Web行分隔符(\n)。机器的行分隔符可以从系统属性行获得。分隔符,但仅当文档在相同类型的计算机上编辑时才有用。对于常规文档,请使用Web行分隔符。

代码示例

代码示例来源:origin: pentaho/mondrian

format.setLineSeparator(LINE_SEP);
} else {
  format.setLineSeparator("");

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

/**
 * Set the format line separator character.
 * @param sep line separator character
 */
public void setLineSeparator(String sep) {
  format.setLineSeparator(sep);
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

/**
 * DOM L3 EXPERIMENTAL:
 * The end-of-line sequence of characters to be used in the XML being
 * written out. The only permitted values are these:
 * <dl>
 * <dt><code>null</code></dt>
 * <dd>
 * Use a default end-of-line sequence. DOM implementations should choose
 * the default to match the usual convention for text files in the
 * environment being used. Implementations must choose a default
 * sequence that matches one of those allowed by  2.11 "End-of-Line
 * Handling". </dd>
 * <dt>CR</dt>
 * <dd>The carriage-return character (#xD).</dd>
 * <dt>CR-LF</dt>
 * <dd> The
 * carriage-return and line-feed characters (#xD #xA). </dd>
 * <dt>LF</dt>
 * <dd> The line-feed
 * character (#xA). </dd>
 * </dl>
 * <br>The default value for this attribute is <code>null</code>.
 */
public void setNewLine(String newLine) {
  serializer._format.setLineSeparator(newLine);
}

代码示例来源:origin: com.rackspace.apache/xerces2-xsd11

private void copySettings(XMLSerializer src, XMLSerializer dest) {
  dest.fDOMErrorHandler = fErrorHandler;
  dest._format.setEncoding(src._format.getEncoding());
  dest._format.setLineSeparator(src._format.getLineSeparator());
  dest.fDOMFilter = src.fDOMFilter;
}//copysettings

代码示例来源:origin: jaxio/celerio

public String format(String unformattedXml) {
  if (!xmlFormatterConfig.isEnableXmlFormatter()) {
    return unformattedXml;
  }
  try {
    final Document document = parseXmlFile(unformattedXml);
    OutputFormat format = new OutputFormat(document);
    format.setLineWidth(xmlFormatterConfig.getMaximumLineWidth());
    format.setIndenting(true);
    format.setIndent(xmlFormatterConfig.getIndent());
    format.setLineSeparator(System.getProperty("line.separator"));
    Writer out = new StringWriter();
    XMLSerializer serializer = new XMLSerializer(out, format);
    serializer.serialize(document);
    return out.toString();
  } catch (Exception e) {
    log.warn("Could not format the content: " + unformattedXml);
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: com.jaxio.celerio/celerio-engine

public String format(String unformattedXml) {
  if (!xmlFormatterConfig.isEnableXmlFormatter()) {
    return unformattedXml;
  }
  try {
    final Document document = parseXmlFile(unformattedXml);
    OutputFormat format = new OutputFormat(document);
    format.setLineWidth(xmlFormatterConfig.getMaximumLineWidth());
    format.setIndenting(true);
    format.setIndent(xmlFormatterConfig.getIndent());
    format.setLineSeparator(System.getProperty("line.separator"));
    Writer out = new StringWriter();
    XMLSerializer serializer = new XMLSerializer(out, format);
    serializer.serialize(document);
    return out.toString();
  } catch (Exception e) {
    log.warn("Could not format the content: " + unformattedXml);
    throw new RuntimeException(e);
  }
}

相关文章