output: Introduce document to output valid XML/HTML.
Strip trailing whitespaces.