I was trying to avoid duplicating code.  toXML is largely the same, but in XHTML5 mode you don't need to 'unhtml5' the markup.