We use this configuration:
CleanerProperties props = new CleanerProperties();
props.setOmitUnknownTags(false);
props.setOmitXmlDeclaration(omitXmlDeclaration);
props.setOmitHtmlEnvelope(true);
props.setTransResCharsToNCR(true);
props.setTransSpecialEntitiesToNCR(true);
And then we use this code to clean an html String called htmlString.
HtmlCleaner cleaner = new HtmlCleaner(props);
TagNode rootTag = cleaner.clean(htmlString);
XmlSerializer serializer = new SimpleXmlSerializer(props);
String cleanHtml = serializer.getAsString(rootTag);
Normally this works fine, but there is a special case this is not working.
Using the String " " (one blank sign, but with 2 or more it is also not working) is returned as "". So htmlString.equals(cleanHtml) is false.
Now, I use the String " check ". After cleaning this String with the code above the result is " check ". So everything's as expected. It seems that a String containing whitespaces is cleaned to an empty String. This is some unexpected :)
Can you pleas check this.
Moing to 2.23 fix list
Its a puzzle all right. I suspect when the content node is created the collapse whitespace algorithm chops it down.