Handling errors in PyXML/SAX
Matt Gerrans
mgerrans at ix.netcom.com
Tue Jul 17 16:29:28 EDT 2001
I don't know the exact answer, but based on a quick look:
Look at the " validate_attributes() member of ValidatingApp, on line 201 of
xmlval.py ("self.parser.report_error(2006,attr)"), in the xml directory
under the python directory. That is where it is printing the message, using
the string 2006 from the localization dictionary in errors.py. You'll have
to dig a little deeper to find out what the (poorly named) attrs variable
is, but seems it is a list of filenames, from which "Unknown" is coming.
Maybe it is a bug that it shows Unknown instead of the filename.
- Matt Gerrans
Tom Bridgman <bridgman at wyeth.gsfc.nasa.gov> wrote in message
news:3B545EB5.6BB5DF57 at wyeth.gsfc.nasa.gov...
> I'm finally starting to work with the SAX parser and DTDs. With the SAX
> defalult error handler, when parsing a file, I get error messages like:
>
> ERROR in Unknown:94:22: Element 'animationtype' not declared
> ERROR in Unknown:98:18: Element 'thumbnail' not declared
> ERROR in Unknown:99:14: Element 'medialist' not declared
>
> which I find ideal but for the fact that I would like to print the file
> name rather than 'Unknown'.
>
> I've tried setting the systemID (which seems to be where the 'Unknown'
> comes from) in a locator object like so:
>
> location=xmlreader.Locator()
> location.setSystemId=inputfilename
> self.handler.setDocumentLocator(location)
>
> but still get 'Unknown'.
>
> The documentation at http://pyxml.sourceforge.net/topics/docs.html is
> really pretty vague on how to use this feature.
>
> Suggestions?
>
> Thanks,
> Tom
> --
> Dr. William T."Tom" Bridgman Scientific Visualization Studio
> Global Science & Technology, Inc. NASA/Goddard Space Flight Center
> Email: bridgman at wyeth.gsfc.nasa.gov Code 935
> Phone: 301-286-1346 Greenbelt, MD 20771
> FAX: TBD http://svs.gsfc.nasa.gov/
More information about the Python-list
mailing list