public void cleanupModel(IDOMModel model) {
if (model == null)
return;
HTMLCleanupProcessorImpl processor = new HTMLCleanupProcessorImpl();
IStructuredCleanupPreferences pref = processor.getCleanupPreferences();
// backup options
boolean compressEmptyElementTags = pref.getCompressEmptyElementTags();
boolean insertRequiredAttrs = pref.getInsertRequiredAttrs();
boolean insertMissingTags = pref.getInsertMissingTags();
boolean quoteAttrValues = pref.getQuoteAttrValues();
boolean formatSource = pref.getFormatSource();
int tagNameCase = pref.getTagNameCase();
int attrNameCase = pref.getAttrNameCase();
// setup options
pref.setCompressEmptyElementTags(true);
pref.setInsertRequiredAttrs(true);
pref.setInsertMissingTags(true);
pref.setQuoteAttrValues(true);
pref.setFormatSource(false);
if (model.getDocument().isXMLType()) { // XHTML
pref.setTagNameCase(HTMLCorePreferenceNames.LOWER);
pref.setAttrNameCase(HTMLCorePreferenceNames.LOWER);
}
else {
pref.setTagNameCase(HTMLCorePreferenceNames.ASIS);
pref.setAttrNameCase(HTMLCorePreferenceNames.ASIS);
}
processor.cleanupModel(model);
// set back options
pref.setCompressEmptyElementTags(compressEmptyElementTags);
pref.setInsertRequiredAttrs(insertRequiredAttrs);
pref.setInsertMissingTags(insertMissingTags);
pref.setQuoteAttrValues(quoteAttrValues);
pref.setFormatSource(formatSource);
pref.setTagNameCase(tagNameCase);
pref.setAttrNameCase(attrNameCase);
}