There should not be two doctypes in the document. >>>>templates/test.tpl <?xml version="1.0" ?> <opt:root> <opt:dtd template="xhtml10transitional" /> <opt:dtd template="xhtml10strict" /> </opt:root> >>>>expected.txt OUTPUT >>>>result.txt <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">