boolean serializeAsArray,
List<String> arrayKeys,
boolean dropRootElement) throws Exception {
MappedNamespaceConvention convention = new PrefixRespectingMappedNamespaceConvention(config);
AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
convention,
new OutputStreamWriter(os, UTF8));
if (serializeAsArray) {
if (arrayKeys != null) {
for (String key : arrayKeys) {
xsw.serializeAsArray(key);
}
} else {
String key = getKey(convention, qname);
xsw.serializeAsArray(key);
}
}
XMLStreamWriter writer = !writeXsiType || dropRootElement
? new IgnoreContentJettisonWriter(xsw, writeXsiType,
dropRootElement ? qname : null) : xsw;