I am using lxml v4.4.1
When I parse a MathML document which use a namespace prefix (for instance xmlns:mml="http://www.w3.org/1998/Math/MathML"
), element and attribute names are prefixed by "{http://www.w3.org/1998/Math/MathML}", which it normal.
example 1:
from lxml import etree
XML1 = """<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" mml:display="block"/>"""
math = etree.XML(XML1)
print(math.tag)
print(math.attrib)
# {http://www.w3.org/1998/Math/MathML}math
# {'{http://www.w3.org/1998/Math/MathML}display': 'block'}
But, when I use the default namespace (eg.: xmlns="http://www.w3.org/1998/Math/MathML"
), attributes are not prefixed by the MathML namespace.
example 2:
XML2 = """<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"/>"""
math = etree.XML(XML2)
print(math.tag)
print(math.attrib)
# {http://www.w3.org/1998/Math/MathML}math
# {'display': 'block'} # <-- WRONG
Is it a bug? How to work around that?