I've tried everything I can think of to effect the object that $document is pointing to in JApplicationSite::dispatch() but it appears to hold a copy of the JFactory::$document instance, not a reference to it. I can change the JFactory::$document to anything I want but since the JApplication ::$document is copied in the dispatch method, it no longer references the JApplication::$document object that I change in my component using JFactory::$application->loadDocument('mydoctype');
Later, then the document is render with JApplication::render(), it does render the correct document type, but its too late, becuase in JAppication::dispatch() the Document type that was copied in JApplicationSite::dispatch() is used to for setBuffer. So there is no way to stop JApplicationSite from setting the buffer using JDocumentHTML.
So later, if the value for the document body is stored incorrectly. In my case, rendering through JDocumentRaw, the component output in stored in $output['component] , when JDocumentRaw just wants a flat string to output, so the result is ARRAY, and strict error.