setDocumentLocator in validating parser (xmlproc)

James Kew james.kew at gmail.com
Fri Mar 18 18:02:05 EST 2005


"Cees Wesseling" <cees at pcraster.nl> wrote in message 
news:6b22838c.0503181241.705ee9e2 at posting.google.com...
> 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.
http://sourceforge.net/tracker/?func=detail&aid=835638&group_id=6473&atid=106473

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.
    self._cont_handler.setDocumentLocator(self)

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

HTH,

James Kew
http://jameskew.blogspot.com





More information about the Python-list mailing list