To facilitate this, the spec should describe how to modify the tree construction algorithm when parsing XHTML. The easiest modification would be to, if the current node is an HTMLTemplateElement, push the HTMLTemplateElement.content DocumentFragment onto the stack of open elements instead of the template element itself. I've experimented with this approach in WebKit's libxml2-based parser and it seems to work reasonably well.
But it is a very ugly approach. (Not that I know any non-ugly approaches.)