[XML-SIG] (no subject)

Lars Marius Garshol larsga at ontopia.net
Mon Jan 5 10:34:47 EST 2004

* Andrew Maclean
| My problem is with the command "parse_resource", which results in a
| SystemExit error.  The test xml file I use can be opened as a file
| and I can use the "feed" command within a while loop to do some
| simple parsing of it (this tells me it finds the file and links my
| XMLProcessor object to the MyApp object) but the minute I try and
| use "parse_resource('C:/test.xml')" it shuts down my Zope instance.

There is only one call to sys.exit() in the xmlproc source code, and
that's in the default ErrorHandler. Probably the problem is that you
are passing an XML document that is not well-formed to xmlproc.

Try adding this to your source code

# --------------------------------------------------

class MyErrorHandler:

    def __init__(self,locator):

    def set_locator(self,loc):

    def get_locator(self):
        return self.locator

    def warning(self,msg):
        "Handles a non-fatal error message."

    def error(self,msg):

    def fatal(self,msg):
        "Handles a fatal error message."
        if self.locator==None:
            print "ERROR: "+msg
            print "ERROR: "+msg+" at %s:%d:%d" % (self.locator.get_current_sysid(),\
            print "TEXT: '%s'" % (self.locator.data[self.locator.pos:\

# --------------------------------------------------

Then change the script as following:

|   file = 'C:/Andy/XSL/test.xml'
|   p = xmlproc.XMLProcessor()
|   p.set_application(MyApp())


|   try:
|     p.parse_resource(file)
|   except IOError, (errno, strerror):
|     print "I/O error(%s): %s" % (errno, strerror)
|   except ValueError:
|     print "Could not convert data to an integer."
|   except:
|     print "Unexpected error:", sys.exc_info()[0]
|     raise
|   print

That should give you an error message when parsing stops because of
the error, and it should take away the sys.exit() call. You can change
where the error message is printed to, of course, if you want.

Lars Marius Garshol, Ontopian         <URL: http://www.ontopia.net >
GSM: +47 98 21 55 50                  <URL: http://www.garshol.priv.no >

More information about the XML-SIG mailing list