setDocumentLocator in validating parser (xmlproc)

James Kew james.kew at
Sat Mar 19 00:02:05 CET 2005

"Cees Wesseling" <cees at> wrote in message 
news:6b22838c.0503181241.705ee9e2 at
> it seems that xmlproc, the default Validating parser, in my setup does
> not call back to setDocumentLocator. Is there anyway to get a locator
> in my handler?

It's a known bug with a simple patch -- I don't know why it wasn't fixed in 
PyXML 0.8.4.

I had the same problem a while ago; I ended up doing a monkeypatch to 
xml.sax.drivers2.drv_xmlproc to add the missing call:

import xml.sax.drivers2.drv_xmlproc

# Override the set_locator method.
def set_locator(self, locator):
    # Existing code.
    self._locator = locator
    # ...but also call the ContentHandler.
    # drv_xmlproc already implements the Locator interface.

setattr(xml.sax.drivers2.drv_xmlproc.XmlprocDriver, "set_locator", 


James Kew

More information about the Python-list mailing list