Extra namespace attrubutes are added when writing with xmlfile
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
lxml |
New
|
Undecided
|
Unassigned |
Bug Description
When generating an XML file using streamed xmlfile, it adds extra namespace declarations:
<root xmlns:g="http://
<items>
<item>
<g:id xmlns:g="http://
</item>
<item>
<g:id xmlns:g="http://
</item>
<item>
<g:id xmlns:g="http://
</item>
<item>
<g:id xmlns:g="http://
</item>
<item>
<g:id xmlns:g="http://
</item>
</items>
</root>
I expect xmlfile to just add element prefix, without repeating the "xmlns:g" attribute for each element, as namespace is already defined in the "root" element.
Expected output:
<root xmlns:g="http://
<items>
<item>
</item>
<item>
</item>
<item>
</item>
<item>
</item>
<item>
</item>
</items>
</root>
I attached a file with the sample script.
Python : sys.version_
lxml.etree : (4, 9, 3, 0)
libxml used : (2, 10, 3)
libxml compiled : (2, 10, 3)
libxslt used : (1, 1, 38)
libxslt compiled : (1, 1, 38)