[XML-SIG] Extended DOM interface proposal.

Fredrik Lundh fredrik@pythonware.com
Mon, 23 Nov 1998 16:30:59 +0100

>  I propose the addition of three methods; these could be functions in 
>a utility module just as easily.  Each method should accept a
>file-like object that supports at least the write() method.  The
>methods are:
> def write_esis(self, file):
>     """Write an ESIS stream on file."""
> def write_sgml(self, file, knownempties=[]):
>     """Write an SGML instance on file.  `knownempties' should
>     be a list of GIs of element types declared to be empty."""
> def write_xml(self, file):
>     """Write an XML instance on file."""
>  Does anyone have any opinions as to whether these should be methods
>or utility functions?  As I think about it, using functions may make
>more sense, esp. since different functions may be needed for different 
>SGML declarations.

IMHO, using objects makes even more sense -- so why
not use the Visitor pattern?

1. add an accept method which takes any object
implementing the DOMVisitor class as its single
argument, and calls the appropriate methods on
that object.

2. the Visitor interface is probably identical to
the SAX API...

3. which leads us back to the DOM->SAX question...

Cheers /F