Empty string namespace on XP in minidom

Discussion in 'Python' started by Gary, Jul 7, 2007.

  1. Gary

    Gary Guest

    Howdy

    I ran into a difference between Python on Windows XP and Linux Fedora
    6.

    Writing a dom to xml with minidom works on Linux. It gives an error on
    XP if there is an empty namespace. The problem was handled in CVS a
    while ago.
    http://mail.python.org/pipermail/xml-sig/2003-October/009904.html

    Here is an example on XP

    Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit
    (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from xml.dom.minidom import parseString
    >>> doc = parseString('<root>value</root>')
    >>> doc.toxml()

    u'<?xml version="1.0" ?><root>value</root>'
    >>> doc = parseString('<root xmlns="">value</root>')
    >>> doc.toxml()

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "C:\tools\Python25\lib\xml\dom\minidom.py", line 45, in toxml
    return self.toprettyxml("", "", encoding)
    File "C:\tools\Python25\lib\xml\dom\minidom.py", line 57, in
    toprettyxml
    self.writexml(writer, "", indent, newl, encoding)
    File "C:\tools\Python25\lib\xml\dom\minidom.py", line 1744, in
    writexml
    node.writexml(writer, indent, addindent, newl)
    File "C:\tools\Python25\lib\xml\dom\minidom.py", line 809, in
    writexml
    _write_data(writer, attrs[a_name].value)
    File "C:\tools\Python25\lib\xml\dom\minidom.py", line 299, in
    _write_data
    data = data.replace("&", "&amp;").replace("<", "&lt;")
    AttributeError: 'NoneType' object has no attribute 'replace'

    and it's working on Linux

    Python 2.4.4 (#1, Oct 23 2006, 13:58:00)
    [GCC 4.1.1 20061011 (Red Hat 4.1.1-30)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from xml.dom.minidom import parseString
    >>> doc = parseString('<root>value</root>')
    >>> doc.toxml()

    u'<?xml version="1.0" ?>\n<root>value</root>'
    >>> doc = parseString('<root xmlns="">value</root>')
    >>> doc.toxml()

    u'<?xml version="1.0" ?>\n<root xmlns="">value</root>'


    Should the library on XP be updated?

    Gary
    Gary, Jul 7, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Boddie
    Replies:
    0
    Views:
    1,341
    Paul Boddie
    Jun 24, 2003
  2. Derek Basch

    Minidom empty script element bug

    Derek Basch, Mar 15, 2005, in forum: Python
    Replies:
    4
    Views:
    584
    Derek Basch
    Mar 16, 2005
  3. Replies:
    3
    Views:
    521
    Stefan Behnel
    Aug 3, 2007
  4. Tzury Bar Yochay
    Replies:
    1
    Views:
    394
    Gabriel Genellina
    Mar 24, 2008
  5. Savvoulidis Iordanis

    Empty gridview cells and checking for empty string

    Savvoulidis Iordanis, Sep 5, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    508
    Savvoulidis Iordanis
    Sep 5, 2008
Loading...

Share This Page