// Clear all inferrable properties from the document.
optimizer.optimizeDocument(document);
StringWriter writer = new StringWriter();
StyledDocumentWriter documentWriter = new StyledDocumentWriter(
writer, styleAttributeName);
DOMDocumentOutputter outputter = new DOMDocumentOutputter(
documentWriter, new DebugCharacterEncoder());
try {