[XML-SIG] Specializing DOM exceptions

uche.ogbuji@fourthought.com uche.ogbuji@fourthought.com
Sat, 25 Nov 2000 18:31:58 -0700


> I'd like to propose an enhancement to the DOM exception classes,
> namely that different codes are mapped to different subclasses:
> 
> class IndexSizeErr(DOMException):
>       code = INDEX_SIZE_ERR
> 
> class DomstringSizeErr(DOMException):
>       code = DOMSTRING_SIZE_ERR
> 
> class HierarchyRequestErr(DOMException):
>       code = HIERARCHY_REQUEST_ERR
> 
> class WrongDocument(DOMException):
>       code = WRONG_DOCUMENT_ERR

I like the idea.  It won't be too hard to do for DOM.  If, however, we were to 
extend the concept to XSLT, that would be quite a bit of work.

> Also, I'd like to make DOMException, the code constants, and the
> derived classes part of the official Python API, so all DOM
> implementations use the same set of exceptions.
> 
> I'd like to re-arrange the internationalization in this code:
> It shouldn't take a %i parameter, since the traceback will read
> 
> IndexSizeErr: DOM Error Code 1: Index error accessing NodeList or NamedNodeMap
> 
> Instead, it should read
> 
> IndexSizeErr: Indexfehler beim Zugriff auf NodeList oder NamedNodeMap

Understood and sensible.

> I'd like to use gettext if available, so that somebody may actually
> consider translating the messages - or drop the idea of translating
> the __str__ representation of a DOM exception.

I'm unclear here.  Is it really so difficult to add a de_DE.py (or whatever) 
for translating the error strings?

When I put in the i18n hooks, I thought about gettext, but it's not available 
in a straightforward manner for Windows and some UNIX systems.  Also, does 
distutils provide any support for gettext database pre-processing?


-- 
Uche Ogbuji                               Principal Consultant
uche.ogbuji@fourthought.com               +1 303 583 9900 x 101
Fourthought, Inc.                         http://Fourthought.com 
4735 East Walnut St, Ste. C, Boulder, CO 80301-2537, USA
Software-engineering, knowledge-management, XML, CORBA, Linux, Python