本文整理了Java中com.sun.org.apache.xml.internal.serialize.OutputFormat
类的一些代码示例,展示了OutputFormat
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OutputFormat
类的具体详情如下:
包路径:com.sun.org.apache.xml.internal.serialize.OutputFormat
类名称:OutputFormat
[英]Sun implementation classes mock-up, for compilation purposes.
[中]Sun实现类模型,用于编译目的。
代码示例来源: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 getPrettyPrint() {
OutputFormat fmt = new OutputFormat("XML", "UTF-8", true);
fmt.setEncoding("UTF-8");
fmt.setIndenting(true);
fmt.setIndent(2);
fmt.setOmitXMLDeclaration(true);
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.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri
/**
* Constructs a new serializer. The serializer cannot be used without
* calling {@link #setOutputCharStream} or {@link #setOutputByteStream}
* first.
*/
public XHTMLSerializer( OutputFormat format )
{
super( true, format != null ? format : new OutputFormat( Method.XHTML, null, false ) );
}
代码示例来源:origin: iTransformers/netTransformer
public String format(String unformattedXml) throws IOException, ParserConfigurationException, SAXException {
final Document document = parseXmlFile(unformattedXml);
OutputFormat format = new OutputFormat(document);
format.setLineWidth(65);
format.setIndenting(true);
format.setIndent(2);
Writer out = new StringWriter();
XMLSerializer serializer = new XMLSerializer(out, format);
serializer.serialize(document);
return out.toString();
}
代码示例来源:origin: SAMLRaider/SAMLRaider
public String getString(Document document, boolean indenting, int indent) throws IOException{
OutputFormat format = new OutputFormat(document);
format.setLineWidth(200);
format.setIndenting(indenting);
format.setIndent(indent);
format.setPreserveEmptyAttributes(true);
format.setEncoding("UTF-8");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLSerializer serializer = new XMLSerializer(baos, format);
serializer.asDOMSerializer();
serializer.serialize(document);
return baos.toString("UTF-8");
}
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
/**
* 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: stackoverflow.com
BufferedReader in = new BufferedReader(new FileReader(fromFile));
FileOutputStream fos = new FileOutputStream(toFile);
OutputFormat of = new OutputFormat("XML","windows-1250",true);
of.setIndent(1);
of.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(fos,of);
ContentHandler hd = serializer.asContentHandler();
代码示例来源:origin: testIT-LivingDoc/livingdoc-core
@Override
public void printTo(Writer out) throws IOException {
if (dom == null) {
return;
}
StringWriter sw = new StringWriter();
OutputFormat format = new OutputFormat(dom);
format.setIndenting(true);
XMLSerializer serializer = new XMLSerializer(sw, format);
serializer.serialize(dom);
out.write(sw.toString());
out.flush();
}
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
/**
* 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.marklogic/marklogic-data-movement-components
@Override
public String generateOutput(DocumentRecord documentRecord) {
if (Format.XML.equals(documentRecord.getFormat())) {
DOMHandle handle = documentRecord.getContent(new DOMHandle());
Document document = handle.get();
OutputFormat format = new OutputFormat(handle.get());
format.setOmitXMLDeclaration(omitXmlDeclaration);
StringWriter writer = new StringWriter();
try {
new XMLSerializer(writer, format).serialize(document);
return writer.toString();
} catch (IOException e) {
throw new RuntimeException("Unable to serialize XML document to string: " + e.getMessage(), e);
}
} else if (logger.isDebugEnabled()) {
logger.debug(String.format("Document '%s' has a format of '%s', so will not attempt to remove the XML declaration from it",
documentRecord.getUri(), documentRecord.getFormat().name()));
}
return documentRecord.getContent(new StringHandle()).get();
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri
/**
* Constructs a new output format with the default values for
* the specified method and encoding. If <tt>indent</tt>
* is true, the document will be pretty printed with the default
* indentation level and default line wrapping.
*
* @param method The specified output method
* @param encoding The specified encoding
* @param indenting True for pretty printing
* @see #setEncoding
* @see #setIndenting
* @see #setMethod
*/
public OutputFormat( String method, String encoding, boolean indenting )
{
setMethod( method );
setEncoding( encoding );
setIndenting( indenting );
}
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
ser.fNamespaces = (features & NAMESPACES) != 0;
ser.fNamespacePrefixes = (features & NSDECL) != 0;
ser._format.setOmitComments((features & COMMENTS)==0);
ser._format.setOmitXMLDeclaration((features & XMLDECL) == 0);
ser._format.setIndenting((features & FORMAT_PRETTY_PRINT) != 0);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-tomcat5
OutputFormat format = new OutputFormat ();
format.setPreserveSpace (true);
StringWriter sw = new StringWriter();
org.w3c.dom.Element rootElement = doc.getDocumentElement();
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
/**
* Constructs a new output format with the proper method,
* document type identifiers and media type for the specified
* document, and with the specified encoding. If <tt>indent</tt>
* is true, the document will be pretty printed with the default
* indentation level and default line wrapping.
*
* @param doc The document to output
* @param encoding The specified encoding
* @param indenting True for pretty printing
* @see #setEncoding
* @see #setIndenting
* @see #whichMethod
*/
public OutputFormat( Document doc, String encoding, boolean indenting )
{
this( doc );
setEncoding( encoding );
setIndenting( indenting );
}
代码示例来源:origin: com.sun.xml.parsers/jaxp-ri
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: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxp-ri
ser._format.setEncoding(encoding);
代码示例来源:origin: it.tidalwave.northernwind/it-tidalwave-html-patches
/**
* 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: gooddata/GoodData-CL
/**
* Dumps the SOAPMessage to String
*
* @param msg the SOAP message
* @return the String representation of the message
* @throws IOException IO issue
* @throws SOAPException SOAP issue
*/
public String dumpSoapMessage(SOAPMessage msg) throws IOException, SOAPException {
Document doc = msg.getSOAPBody().getOwnerDocument();
OutputFormat format = new OutputFormat(doc);
format.setLineWidth(65);
format.setIndenting(true);
format.setIndent(2);
StringWriter s = new StringWriter();
XMLSerializer serializer = new XMLSerializer(s, format);
serializer.serialize(doc);
return s.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;
}
内容来源于网络,如有侵权,请联系作者删除!