Short version : How to add the xmlns:xi="http://www.w3.org/2001/XInclude" prefix decleration to my root element in python with lxml ?
Context :
I have some XML files that include IDs to other files.
These IDs represent the referenced file names.
Using lxml I managed to replace these with the appropriate XInclude statement, but if I do not have the prefix decleration my my XML parser won't add the includes, which is normal.
Edit : I won't include my code because it won't help at understanding the problem. I can process the document just fine, my problem is serialization.
So from this
<root>
<somechild/>
</root>
I want to get this <root xmlns:xi="http://www.w3.org/2001/XInclude">
<somechild/>
</root>
in my output file.
For this I tried using
`
tree = ET.parse(fileName)
root = tree.getroot()
root.nsmap['xi'] = "http://www.w3.org/2001/XInclude"
tree.write('output.xml', xml_declaration=True, encoding="UTF-8", pretty_print=True)
`