Document document,
String prefix) {
if (logger.isDebugEnabled()) {
try {
StringWriter writer = new StringWriter();
DOMDocumentOutputter outputter = new DOMDocumentOutputter(
new XMLDocumentWriter(writer),
protocol.getCharacterEncoder());
// Tell the outputter to display null elements so we can
// eliminate them more easily - null element names are evil!
outputter.setDebugNullElementNames(true);
outputter.output(document);
logger.debug(prefix + ": " + writer.toString());
} catch (Exception e) {
logger.debug("Failed to log the transformer DOM", e);
}