[XML-SIG] SAX Namespaces
Greg Stein
gstein@lyra.org
Mon, 3 Jul 2000 20:32:50 -0700
Just realized that I wanted to state why the other forms aren't as nice...
On Mon, Jul 03, 2000 at 08:24:58PM -0700, Greg Stein wrote:
>...
> I would take option (1) or (3). qname would be the prefix used. If NS
> processing *can* be disabled, then uri==None and name==qname.
>...
> On Mon, Jul 03, 2000 at 09:14:38PM -0500, Paul Prescod wrote:
>...
> > #2. def startElement( self, (uri,localname,qname), attrs ):
This form is a bit more difficult to work with the uri/localname pair when
doing processing.
>...
> > #4. def startElement( self, name, attrs ):
> > ....
> >
> > Depending on whether you have turned on namespace processing, "name" is
> > either "string" or (uri,localname,qname)
This introduces a "mode" into the API. Depending on some flag, you get
entirely different data. Further, the presence of qname in there means that
"name" is useless unless pulled apart (otherwise A:name and B:name are
distinct). This means that we have some functions that do:
def startElement_mode1(self, name, attrs):
if name == 'elem': ...
def startElement_mode2(self, (uri, localname, qname), attrs):
if (uri, localname) == LOOKING_FOR: ...
In essence the variant structure of the return value does a disservice to
creating a standard API. Depending on how the event generator is set up, you
could get entirely different data.
[ and we won't even go into a handler that must do an isinstance() to check
to see which form was passed... ]
>...
> > #5. def startElement( self, name, atrs ):
> > ....
> >
> > Same description and questions as above.
Unknown. Unless something funny is going on in here, this might simply be a
variant of the tuple-unpacking-declaration of the functions above. In other
words, the folllowing two signatures are the same:
def startElement(self, name, attrs):
def startElement(self, (uri, localname, qname), attrs):
It is just that the second does a bit of automatic tuple-unpacking on entry
to the function. (and the latter will raise an error if it isn't passed a
3-item tuple)
Cheers,
-g
--
Greg Stein, http://www.lyra.org/