Author silverbacknet
Recipients silverbacknet
Date 2013-01-31.02:35:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
ET reads a default-namespaced (xmnls="whatever") file correctly but won't write it back out.

The error given is:
ValueError: cannot use non-qualified names with default_namespace option

The XML reference is reasonably clear on this:
"Default namespace declarations do not apply directly to attribute names;"
"The namespace name for an unprefixed attribute name always has no value."

Therefore, it is not an error to write non-qualified _attribute_ names with a default namespace; they're just considered un-namespaced anyway. The trivial case where a file is read in with a default namespace and written out with the same one should make it obvious:

from xml.etree.ElementTree import *
register_namespace('svg', '')
svg = ElementTree(XML("""
<svg width="12cm" height="4cm" viewBox="0 0 1200 400" xmlns="" version="1.1">
<rect x="1" y="1" width="1198" height="398" fill="none" stroke="blue" stroke-width="2" />

Yet this will fail with the error above. By leaving off default_namespace, every element is pointlessly prefixed by 'svg:' in the resulting file, but it does work.
Date User Action Args
2013-01-31 02:35:07silverbacknetsetrecipients: + silverbacknet
2013-01-31 02:35:07silverbacknetsetmessageid: <>
2013-01-31 02:35:07silverbacknetlinkissue17088 messages
2013-01-31 02:35:06silverbacknetcreate