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

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

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

OutputFormat.setPreserveSpace介绍

[英]Sets space preserving as the default behavior. The default is space stripping and all elements that do not specify otherwise or use the default value will not preserve spaces.
[中]将保留空间设置为默认行为。默认设置为空间剥离,所有未另行指定或未使用默认值的图元都不会保留空间。

代码示例

代码示例来源: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: edu.internet2.middleware.grouper/grouper-ui

format.setPreserveSpace(true);
format.setIndenting(true);
StringWriter w = new StringWriter();

代码示例来源:origin: info.magnolia.activation/magnolia-module-activation

outputFormat.setPreserveSpace(false);

代码示例来源: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: org.w3c.jigsaw/jigsaw

true);
format.setOmitXMLDeclaration(false);
format.setPreserveSpace(false);
XMLSerializer serializer = new XMLSerializer(out, format);
try {

代码示例来源:origin: org.w3c.jigsaw/jigsaw

protected synchronized void saveDeadProperties() {
if (deadpropmodified) {
  ArrayDictionary dic  = new ArrayDictionary(deadindex.size());
  Enumeration    denum = deadindex.keys();
  while (denum.hasMoreElements()) {
  String                ns     = (String)denum.nextElement();
  Document              doc    = (Document)deadindex.get(ns);
  ByteArrayOutputStream out    = new ByteArrayOutputStream();
  OutputFormat          format = 
    new OutputFormat(doc, WEBDAV.ENCODING, true);
  format.setOmitXMLDeclaration(false);
  format.setPreserveSpace(true);
  XMLSerializer serializer = new XMLSerializer(out, format);
  try {
    serializer.serialize(doc);
    if (debug)
    System.out.println("["+out.toString(WEBDAV.ENCODING)
          +"]");
    Base64Encoder encoder = 
    new Base64Encoder(out.toString(WEBDAV.ENCODING));
    dic.put(ns, encoder.processString());
  } catch (IOException ex) {
    ex.printStackTrace();
  }
  }
  setValue(ATTR_DEAD_PROPERTIES, dic);
  deadpropmodified = false;
}
}

代码示例来源:origin: org.w3c.jigsaw/jigsaw

true);
format.setOmitXMLDeclaration(false);
format.setPreserveSpace(false);
XMLSerializer serializer = new XMLSerializer(out, format);
try {

代码示例来源:origin: org.w3c.jigsaw/jigsaw

private synchronized void saveLockOwner() {
if (ownerNode != null) {
  Document doc = DAVBody.createDocument(DAVNode.OWNER_NODE);
  DAVNode.exportChildren(doc, 
        doc.getDocumentElement(), 
        ownerNode, 
        true);
  ByteArrayOutputStream out    = new ByteArrayOutputStream();
  OutputFormat          format = 
  new OutputFormat(doc, WEBDAV.ENCODING, true);
  format.setOmitXMLDeclaration(false);
  format.setPreserveSpace(true);
  XMLSerializer serializer = new XMLSerializer(out, format);
  try {
  serializer.serialize(doc);
  if (debug)
    System.out.println("["+out.toString(WEBDAV.ENCODING)+"]");
  Base64Encoder encoder = 
    new Base64Encoder(out.toString(WEBDAV.ENCODING));
  setValue(ATTR_LOCK_OWNER, encoder.processString());
  } catch (IOException ex) {
  ex.printStackTrace();
  }
}
}

代码示例来源: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.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 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 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: 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.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: com.atlassian.jersey/atlassian-jersey-restdoc

private static XMLSerializer getXMLSerializer( OutputStream os, String[] cdataElements ) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  // configure an OutputFormat to handle CDATA
  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
  XMLSerializer serializer = new XMLSerializer(of);
  serializer.setOutputByteStream( os );
  return serializer;
}

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

相关文章