#224 GetDOMImplementation failure when cssutils installed

PyXB 1.2.4
PyXB 1.2.3
Dylan Jay

cssutils installs itself as a DOMImplementation with certain features. It's not a full implementation. PyXB doesn't call xml.dom.getDOMImplementation() with any features or a specific implementation therefore gets cssutils and then breaks with an error like

File "/Users/dylanjay/Projects/download-cache/eggs/PyXB-1.2.3-py2.7.egg/pyxb/binding/basis.py", line 539, in toxml

dom = self.toDOM(bds)

File "/Users/dylanjay/Projects/download-cache/eggs/PyXB-1.2.3-py2.7.egg/pyxb/binding/basis.py", line 502, in toDOM

bds = domutils.BindingDOMSupport()

File "/Users/dylanjay/Projects/download-cache/eggs/PyXB-1.2.3-py2.7.egg/pyxb/utils/domutils.py", line 477, in init


File "/Users/dylanjay/Projects/download-cache/eggs/PyXB-1.2.3-py2.7.egg/pyxb/utils/domutils.py", line 439, in reset

self.document = self.implementation().createDocument(None, None, None)

File "/Users/dylanjay/Projects/download-cache/eggs/cssutils-1.0-py2.7.egg/cssutils/init.py", line 166, in createDocument

raise NotImplementedError


if instead the call was xml.dom.getDOMImplementation(features=['core','xml 2.0']) or similar, the problem is avoided.


  • Peter A. Bigot

    Peter A. Bigot - 2014-01-14
    • priority changed from major to minor
    • status changed from new to assigned
    • component changed from Binding model to Code
    • milestone set to PyXB 1.2.4

    I've never come across a DOM implementation that didn't support core or xml, but it appears to be a legitimate situation. As a work-around while I figure out exactly what levels are required (looks like core 2.0 and xml 2.0), you can use pyxb.dom.setDOMImplementation() to override the default.

  • Peter A. Bigot

    Peter A. Bigot - 2014-01-14
    • status changed from assigned to closed
    • resolution set to fixed

    The workaround is to use this in the code that imports cssutils:

    import pyxb.utils.domutils
    import xml.dom
    pyxb.utils.domutils.SetDOMImplementation(xml.dom.getDOMImplementation(None, (('core', '2.0'), ('xml', '2.0'))))

    The fix is in the next branch:

    commit 1dd653935b4368abbc1f3c17b992840d6a3a3fbb
    Author: Peter A. Bigot <pab@pabigot.com>
    Date:   Tue Jan 14 07:53:41 2014 -0600
        trac/224: GetDOMImplementation failure when cssutils installed
        DOM implementations are not obligated to support Core DOM interfaces, or
        even XML.  Supply the features PyXB requires.  Verified with an external
        application that loads cssutils (which registers an incomplete DOM
        implementation) before invoking PyXB operations.
  • Peter A. Bigot

    Peter A. Bigot - 2014-01-14

    Thanks for the report and the clue to how to fix it.


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks