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

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

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

OutputFormat.setLineWidth介绍

[英]Sets the line width. If zero then no line wrapping will occur. Calling #setIndenting will reset this value to zero (off) or the default (on).
[中]设置线宽。如果为零,则不会发生换行。调用#setIndenting会将该值重置为零(off)或默认值(on)。

代码示例

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

} else {
  format = new OutputFormat("xml", null, prettyPrint);
  format.setLineWidth(0); // don't wrap lines

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

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

代码示例来源:origin: stackoverflow.com

OutputStream outputStream = new FileOutputStream(new File(xMLFilePath));
 OutputFormat outputFormat = new OutputFormat(doc, "UTF-8", true);
 outputFormat.setOmitComments(true);
 outputFormat.setLineWidth(0);
 XMLSerializer serializer = new XMLSerializer(outputStream, outputFormat);
 serializer.serialize(doc);
 outputStream.close();

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

@Deprecated
private static OutputFormat getOutputFormat(boolean omitXMLDeclaration,
                      boolean omitDocumentType) {
  OutputFormat format = new OutputFormat(Method.XML, "UTF-8", true);
  format.setIndent(2);
  format.setLineWidth(80);
  if (omitXMLDeclaration) {
    format.setOmitXMLDeclaration(true);
  }
  if (omitDocumentType) {
    format.setOmitDocumentType(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: 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: 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: 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: 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: 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.opengis.cite/cite1-utils

public static void writeXml(Element element, OutputStream os)
 throws IOException
{
 OutputFormat format = new OutputFormat("XML", "UTF-8", false);
 format.setOmitComments(false);
 format.setLineWidth(0);
 XMLSerializer serializer = new XMLSerializer(format);
 serializer.setOutputByteStream(os);
 serializer.serialize(element);
}

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

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

相关文章