Instead of using this xhtml_template, you should pass the content through tidy with the -asxhtml switch on.
This will produce a valid xhtml file that passes epub validation (http://code.google.com/p/epubcheck/).
This will produce a valid xhtml file that passes epub validation (http://code.google.com/p/epubcheck/).