xhtml: factor out text/cdata processing into a helper method