Prevent xmlns="" in stream output.

This was causing problems for HTML-IM because the HTML is parsed
without a namespaced context.

While xmlns="" technically can be valid, it's usually wrong, so this will work
for now until the HTML-IM parsing is fixed.
This commit is contained in:
Lance Stout 2012-10-15 22:22:07 -07:00
parent ef48a8c4d9
commit 4190027a78

View File

@ -70,6 +70,7 @@ def tostring(xml=None, xmlns='', stream=None,
# Output the tag name and derived namespace of the element. # Output the tag name and derived namespace of the element.
namespace = '' namespace = ''
if tag_xmlns:
if top_level and tag_xmlns not in [default_ns, xmlns, stream_ns] \ if top_level and tag_xmlns not in [default_ns, xmlns, stream_ns] \
or not top_level and tag_xmlns != xmlns: or not top_level and tag_xmlns != xmlns:
namespace = ' xmlns="%s"' % tag_xmlns namespace = ' xmlns="%s"' % tag_xmlns