[XML-SIG] SAX Namespaces

Greg Stein gstein@lyra.org
Thu, 6 Jul 2000 15:30:09 -0700


On Thu, Jul 06, 2000 at 02:53:17PM -0500, Paul Prescod wrote:
> "Fred L. Drake, Jr." wrote:
>...
> > The usage pattern we observed in Grail was that we'd set up default
> > values in locals, loop over the attributes list to set up locals, and
> > then use the locals while doing whatever we needed to do.  It was a
> > real pain if we needed to branch on one attribute and then only use
> > some others in one branch or another; we still had to loop and extract
> > first, and then do the application work.  We couldn't branch on the
> > one that mattered, and then get the others only as needed.  Unless we
> > looped more than once, which is heinous.
> 
> I would encapsulate this behavior in the wrapper class. That's what I
> meant by "lazy indexing." You ask for one attribute and an internal
> dictionary "remembers" where it found it. You ask for another and it
> remembers where it found that. If you only ask by URN/localname pair
> then you don't incur the cost of indexing by qname and if you only ask
> by qname then you don't incur the cost of indexing by pair.

Holy smokes. That is awfully complicated. Why the "lazy indexing?" A
dictionary works quite well here. Stuff them in a dictionary and you're
done.

>...
> Here is one way of looking at it. Let's say that there are four popular
> APIs out there:
> 
> SAX
> DOM
> Pyxie
> QP_xml
> 
> Let's say an equal number of people use all four. Finally, let's say
> that all but SAX are built on SAX. 
> 
> If this is the case, then 75% of all Python SAX users are going to be
> using APIs that immediately copy attributes into a list (which all of
> the non-SAX APIs do today) and 25% are going to be using the
> dictionary-structure directly.

qp_xml will also use the dictionary. As I said in the other note, it doesn't
today because it is doing the NS processing itself. Let Expat do that, and
all the pain goes away.

> And even some subset of the 25% may find
> that the dictionary is sub-optimal because it is indexed based on the
> wrong property or properties.

How can (URI, name) be the wrong index? That is the name of the dumb thing.
qname certainly isn't because you can't know what prefix was used.

Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/