// ok, now the namespace map has all the prefixes.
String enc = HttpUtils.getSetEncoding(m, headers, "UTF-8");
XMLStreamWriter xmlStreamWriter = createStreamWriter(aegisType.getSchemaType(), enc, os);
xmlStreamWriter.writeStartDocument();
StaxUtils.copy(dom, xmlStreamWriter);
// Jettison needs, and StaxUtils.copy doesn't do it.
xmlStreamWriter.writeEndDocument();
xmlStreamWriter.flush();
xmlStreamWriter.close();