Switch to parsing XML/HTML fragments using a wrapper document that includes a doctype.

This preserves both the case of attributes and any named entity references from MathML.
Fix CDATA shenanigans that appeared after the previous commit.

This also extends the tests for issue #40 and squashes a bunch of bugs around CDATA, mostly using hacks.