Trim whitespace.
Wrap the XML declaration and the doctype in STR.
Whitespace.
Whitespace.