One of the essential features of XSLT is that the type of the output document is not known. Thus modifications of an existing document can not be conformant to both the XSLT spec and the HTML spec. Transforming into an existing document is really brittle and the expected result is vague. Whether you want to replace parts of an existing document or add content by XSLT is unknown to the implementation, though both are valid use cases. Thus we introduced the transformToFragment, which gives you the level of control you deserve while still supporting both XML and HTML output methods as good as possible. It's not a bug, it's a feature. Really.