private OMDocumentImplUtil() {}
public static void internalSerialize(OMDocument document, XMLStreamWriter writer2,
boolean cache, boolean includeXMLDeclaration) throws XMLStreamException {
MTOMXMLStreamWriter writer = (MTOMXMLStreamWriter) writer2;
if (includeXMLDeclaration) {
//Check whether the OMOutput char encoding and OMDocument char
//encoding matches, if not use char encoding of OMOutput
String encoding = writer.getCharSetEncoding();
if (encoding == null || "".equals(encoding)) {
encoding = document.getCharsetEncoding();
}
String version = document.getXMLVersion();
if (version == null) {
version = "1.0";
}
if (encoding == null) {
writer.getXmlStreamWriter().writeStartDocument(version);
} else {
writer.getXmlStreamWriter().writeStartDocument(encoding, version);
}
}
if (cache || document.isComplete() || document.getBuilder() == null) {
OMSerializerUtil.serializeChildren(document, writer, cache);