org.dom4j.io.OutputFormat.setNewlines()方法的使用及代码示例

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

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

OutputFormat.setNewlines介绍

[英]DOCUMENT ME!
[中]记录我!

代码示例

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

//Prepare JAXB objects
JAXBContext jc = JAXBContext.newInstance("jaxb.package");
Marshaller m = jc.createMarshaller();

//Define an output file
File output = new File("test.xml");

//Create a filter that will remove the xmlns attribute      
NamespaceFilter outFilter = new NamespaceFilter(null, false);

//Do some formatting, this is obviously optional and may effect performance
OutputFormat format = new OutputFormat();
format.setIndent(true);
format.setNewlines(true);

//Create a new org.dom4j.io.XMLWriter that will serve as the 
//ContentHandler for our filter.
XMLWriter writer = new XMLWriter(new FileOutputStream(output), format);

//Attach the writer to the filter       
outFilter.setContentHandler(writer);

//Tell JAXB to marshall to the filter which in turn will call the writer
m.marshal(myJaxbObject, outFilter);

代码示例来源:origin: mulesoft/mule

private String renderSchema(Schema schema) {
  try {
   JAXBContext jaxbContext = JAXBContext.newInstance(Schema.class);
   Marshaller marshaller = jaxbContext.createMarshaller();
   NamespaceFilter outFilter = new NamespaceFilter(CORE_PREFIX, CORE_NAMESPACE, true);
   OutputFormat format = new OutputFormat();
   format.setIndent(true);
   format.setNewlines(true);

   StringWriter sw = new StringWriter();
   XMLWriter writer = new XMLWriter(sw, format);
   outFilter.setContentHandler(writer);
   marshaller.marshal(schema, outFilter);
   return sw.toString();
  } catch (JAXBException e) {
   throw new RuntimeException(e);
  }

 }
}

代码示例来源:origin: org.dom4j/dom4j

/**
   * A static helper method to create the default compact format. This format
   * does not have any indentation or newlines after an alement and all other
   * whitespace trimmed
   * 
   * @return DOCUMENT ME!
   */
  public static OutputFormat createCompactFormat() {
    OutputFormat format = new OutputFormat();
    format.setIndent(false);
    format.setNewlines(false);
    format.setTrimText(true);

    return format;
  }
}

代码示例来源:origin: org.dom4j/dom4j

setEncoding(args[++i]);
} else if (args[i].equals("-newlines")) {
  setNewlines(true);
} else if (args[i].equals("-lineSeparator")) {
  setLineSeparator(args[++i]);

代码示例来源:origin: org.dom4j/dom4j

/**
 * A static helper method to create the default pretty printing format. This
 * format consists of an indent of 2 spaces, newlines after each element and
 * all other whitespace trimmed, and XMTML is false.
 * 
 * @return DOCUMENT ME!
 */
public static OutputFormat createPrettyPrint() {
  OutputFormat format = new OutputFormat();
  format.setIndentSize(2);
  format.setNewlines(true);
  format.setTrimText(true);
  format.setPadText(true);
  return format;
}

代码示例来源:origin: org.dom4j/dom4j

StringWriter sw = new StringWriter();
OutputFormat format = OutputFormat.createPrettyPrint();
format.setNewlines(newlines);
format.setTrimText(trim);
format.setXHTML(isXHTML);

代码示例来源:origin: org.dom4j/dom4j

currentFormat.setNewlines(false);
  currentFormat.setTrimText(false);
  currentFormat.setIndent("");
} finally {
  FormatState state = (FormatState) formatStack.pop();
  currentFormat.setNewlines(state.isNewlines());
  currentFormat.setTrimText(state.isTrimText());
  currentFormat.setIndent(state.getIndent());

代码示例来源:origin: org.mule.modules/mule-module-xml

/**
 * @see OutputFormat#setNewlines(boolean)
 */
public synchronized void setNewlines(boolean newlines)
{
  outputFormat.setNewlines(newlines);
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

public static OutputFormat createPrettyPrint() {
  OutputFormat format = new OutputFormat();
  format.setIndentSize(2);
  format.setNewlines(true);
  return format;
}

代码示例来源:origin: org.nuxeo.ecm.core/nuxeo-core-io

public static OutputFormat createCompactFormat() {
  OutputFormat format = new OutputFormat();
  format.setIndent(false);
  format.setNewlines(false);
  return format;
}

代码示例来源:origin: org.dom4j/com.springsource.org.dom4j

/**
   * A static helper method to create the default compact format. This format
   * does not have any indentation or newlines after an alement and all other
   * whitespace trimmed
   * 
   * @return DOCUMENT ME!
   */
  public static OutputFormat createCompactFormat() {
    OutputFormat format = new OutputFormat();
    format.setIndent(false);
    format.setNewlines(false);
    format.setTrimText(true);

    return format;
  }
}

代码示例来源:origin: dom4j/dom4j

/**
   * A static helper method to create the default compact format. This format
   * does not have any indentation or newlines after an alement and all other
   * whitespace trimmed
   * 
   * @return DOCUMENT ME!
   */
  public static OutputFormat createCompactFormat() {
    OutputFormat format = new OutputFormat();
    format.setIndent(false);
    format.setNewlines(false);
    format.setTrimText(true);

    return format;
  }
}

代码示例来源:origin: com.github.developframework/kite-core

@Override
public void outputXml(Writer writer, DataModel dataModel, String namespace, String templateId, boolean isPretty) {
  Document document = constructDocument(dataModel, namespace, templateId);
  try {
    OutputFormat format = new OutputFormat();
    format.setIndent(isPretty);
    format.setNewlines(isPretty);
    format.setSuppressDeclaration(kiteConfiguration.isXmlSuppressDeclaration());
    XMLWriter xmlWriter = new XMLWriter(writer, format);
    xmlWriter.write(document);
    xmlWriter.close();
  } catch (IOException e) {
    throw new KiteException("produce xml string failed.");
  }
}

代码示例来源:origin: org.dom4j/org.motechproject.org.dom4j

/**
 * A static helper method to create the default pretty printing format. This
 * format consists of an indent of 2 spaces, newlines after each element and
 * all other whitespace trimmed, and XMTML is false.
 * 
 * @return DOCUMENT ME!
 */
public static OutputFormat createPrettyPrint() {
  OutputFormat format = new OutputFormat();
  format.setIndentSize(2);
  format.setNewlines(true);
  format.setTrimText(true);
  format.setPadText(true);
  return format;
}

代码示例来源:origin: dom4j/dom4j

/**
 * A static helper method to create the default pretty printing format. This
 * format consists of an indent of 2 spaces, newlines after each element and
 * all other whitespace trimmed, and XMTML is false.
 * 
 * @return DOCUMENT ME!
 */
public static OutputFormat createPrettyPrint() {
  OutputFormat format = new OutputFormat();
  format.setIndentSize(2);
  format.setNewlines(true);
  format.setTrimText(true);
  format.setPadText(true);
  return format;
}

代码示例来源:origin: maven/dom4j

/**
 * A static helper method to create the default pretty printing format. This
 * format consists of an indent of 2 spaces, newlines after each element and
 * all other whitespace trimmed, and XMTML is false.
 * 
 * @return DOCUMENT ME!
 */
public static OutputFormat createPrettyPrint() {
  OutputFormat format = new OutputFormat();
  format.setIndentSize(2);
  format.setNewlines(true);
  format.setTrimText(true);
  format.setPadText(true);
  return format;
}

代码示例来源:origin: dom4j/dom4j

private void testGitHubIssue26(final Element element) throws IOException {
  final OutputFormat format = new OutputFormat("    ", true);
  format.setSuppressDeclaration(false);
  format.setTrimText(true);
  format.setPadText(true);
  format.setNewlines(true);
  new XMLWriter(new CharArrayWriter(128), format).write(element);
}

代码示例来源:origin: com.intoverflow.booster/booster-core

public static OutputFormat createPrettyPrint() {
  // OutputFormat format= OutputFormat.createPrettyPrint();
  OutputFormat format = new OutputFormat();
  format.setIndentSize(2);
  format.setIndent("\t");
  format.setNewlines(true);
  format.setTrimText(true);
  format.setPadText(true);
  format.setNewLineAfterDeclaration(false);
  return format;
}

代码示例来源:origin: com.intoverflow.base/intoverflow-util

public static OutputFormat createPrettyPrint() {
  // OutputFormat format= OutputFormat.createPrettyPrint();
  OutputFormat format = new OutputFormat();
  format.setIndentSize(2);
  format.setIndent("\t");
  format.setNewlines(true);
  format.setTrimText(true);
  format.setPadText(true);
  format.setNewLineAfterDeclaration(false);
  return format;
}

代码示例来源:origin: dom4j/dom4j

public void testGitHubIssue26_case7() throws IOException {
  final Element element = new DOMElement("foo");
  element.add(new DOMText(""));
  element.add(new DOMElement("elem"));
  final OutputFormat format = new OutputFormat("    ", true);
  format.setSuppressDeclaration(false);
  format.setTrimText(false);
  format.setPadText(true);
  format.setNewlines(true);
  new XMLWriter(new CharArrayWriter(128), format).write(element);
}

相关文章