protected void marshal(Object obj, Class<?> cls, Type genericType,
String enc, OutputStream os, MediaType mt,
Annotation[] anns) throws Exception {
obj = convertToJaxbElementIfNeeded(obj, cls, genericType);
if (obj instanceof JAXBElement && cls != JAXBElement.class) {
cls = JAXBElement.class;
}
Marshaller ms = createMarshaller(obj, cls, genericType, enc);
if (!nsPrefixes.isEmpty()) {
setNamespaceMapper(ms, nsPrefixes);
}
addAttachmentMarshaller(ms);
addProcessingInstructions(ms, anns);
addSchemaLocation(ms, anns);
marshal(obj, cls, genericType, enc, os, mt, ms);
}