pi = dom.createProcessingInstruction('xml-stylesheet',
    'type="text/xsl" href="mystyle.xslt"')
root = dom.firstChild
dom.insertBefore(pi, root)
print(dom.toprettyxml())
How to add an xml-stylesheet processing instruction node with Python 2.6 and minidom?