StringBuilder filteredXhtml = new StringBuilder();
if (message.getFirstChild() != null) {
// Render an XHTML string containing the message content, with embedded
// <ph> elements.
StringBuilder xhtml = new StringBuilder();
RenderContext rc = new RenderContext(new Concatenator(xhtml))
.withMarkupRenderMode(MarkupRenderMode.XML);
for (Node c : Nodes.childrenOf(message)) {
Nodes.render(c, rc);
}
rc.getOut().noMoreTokens();
HtmlLexer lexer = new HtmlLexer(
CharProducer.Factory.fromString(
xhtml.toString(),
Nodes.getFilePositionFor(message.getFirstChild())));
lexer.setTreatedAsXml(true);