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

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

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

OutputFormat.<init>介绍

[英]Constructs a new output format with the default values.
[中]使用默认值构造新的输出格式。

代码示例

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

private static XMLSerializer getXMLSerializer(final OutputStream os, final String[] cdataElements)
    throws InstantiationException,
    IllegalAccessException, ClassNotFoundException {
  // configure an OutputFormat to handle CDATA
  final OutputFormat of = new OutputFormat();
  // specify which of your elements you want to be handled as CDATA.
  // The use of the '^' between the namespaceURI and the localname
  // seems to be an implementation detail of the xerces code.
  // When processing xml that doesn't use namespaces, simply omit the
  // namespace prefix as shown in the third CDataElement below.
  of.setCDataElements(cdataElements);
  // set any other options you'd like
  of.setPreserveSpace(true);
  of.setIndenting(true);
  // create the serializer
  final XMLSerializer serializer = new XMLSerializer(of);
  serializer.setOutputByteStream(os);
  return serializer;
}

代码示例来源:origin: graphhopper/jsprit

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

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

public static void validate(
  Document doc,
  String schemaLocationPropertyValue,
  EntityResolver resolver)
  throws IOException,
  SAXException
{
  OutputFormat format  = new OutputFormat(doc, null, true);
  StringWriter writer = new StringWriter(1000);
  XMLSerializer serial = new XMLSerializer(writer, format);
  serial.asDOMSerializer();
  serial.serialize(doc);
  String docString = writer.toString();
  validate(docString, schemaLocationPropertyValue, resolver);
}

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

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

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

/**
 * Constructs a new serializer. The serializer cannot be used without
 * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
 * first.
 */
public HTMLSerializer( OutputFormat format )
{
  this( false, format != null ? format : new OutputFormat( Method.HTML, "ISO-8859-1", false ) );
}

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

/**
 * Constructs a new serializer. The serializer cannot be used without
 * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
 * first.
 */
public HTMLSerializer()
{
  this( false, new OutputFormat( Method.HTML, "ISO-8859-1", false ) );
}

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

/**
 * Constructs a new serializer that writes to the specified output
 * stream using the specified output format. If <tt>format</tt>
 * is null, will use a default output format.
 *
 * @param output The output stream to use
 * @param format The output format to use, null for the default
 */
public XML11Serializer( OutputStream output, OutputFormat format ) {
  super( output, format != null ? format : new OutputFormat( Method.XML, null, false ) );
  _format.setVersion("1.1");
}

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

/**
 * Constructs a new serializer. The serializer cannot be used without
 * calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
 * first.
 */
public XMLSerializer( OutputFormat format ) {
  super( format != null ? format : new OutputFormat( Method.XML, null, false ) );
  _format.setMethod( Method.XML );
}

代码示例来源:origin: org.kuali.maven.impex/torque-generator

/**
 * This is the XMLSerializer responsible for outputting the XML document
 */
protected XMLSerializer getSerializer(final Writer out) {
  return new XMLSerializer(out, new OutputFormat(Method.XML, getEncoding(), true));
}

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

private void writeDocument(Document document, OutputStream out) throws IOException
{
  XMLSerializer serializer = new XMLSerializer(out, new OutputFormat(document, null, true));
  serializer.serialize(document);
}

代码示例来源:origin: org.geoserver.extension/wps-core

/**
 * Encodes the internal object representation of a parameter as a string.
 */
public void encode( Object value, OutputStream os) throws Exception {
  // create the document serializer
  XMLSerializer serializer = new XMLSerializer(os, new OutputFormat());
  serializer.setNamespaces(true);
  // cascade on the other encode method
  encode(value, serializer);
}

代码示例来源:origin: org.nuxeo.common/nuxeo-common

public static String toStringOmitXml(Element element) throws IOException {
  OutputFormat of = new OutputFormat();
  of.setOmitXMLDeclaration(true);
  return toString(element, of);
}

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-forms-layout-core

@XContent("description")
public void setDescription(DocumentFragment descriptionDOM) {
  try {
    OutputFormat of = new OutputFormat();
    of.setOmitXMLDeclaration(true);
    this.description = DOMSerializer.toString(descriptionDOM, of).trim();
  } catch (IOException e) {
    log.error(e, e);
  }
}

代码示例来源:origin: pentaho/pentaho-platform

private static XMLSerializer getXMLSerializer( OutputStream os )
  throws InstantiationException, IllegalAccessException, ClassNotFoundException {
 OutputFormat of = new OutputFormat();
 of.setCDataElements( new String[] { "ns1^commentText", "ns2^commentText", "^commentText" } );
 XMLSerializer serializer = new XMLSerializer( of );
 serializer.setOutputByteStream( os );
 return serializer;
}

代码示例来源: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: 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: org.wso2.bpel/ode-utils

public static ContentHandler getXercesSerializer(OutputStream os) {
  XMLSerializer serializer =  new XMLSerializer();
  OutputFormat format = new OutputFormat();
  format.setPreserveSpace(true);
  format.setOmitDocumentType(true);
  serializer.setOutputFormat(format);
  serializer.setOutputByteStream(os);
  return serializer;

 }
}

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

相关文章