[XML-SIG] DOM Extension Proposal

Paul Prescod paul@prescod.net
Thu, 22 Jun 2000 10:02:45 -0500

Lars Marius Garshol wrote:
> ...
> I have been wondering why we even have Attribute nodes in the DOM tree
> at all. They are mainly useful for representing entity references in
> attribute values, something that is very rarely useful. :-)

Attributes can also be independently addressed as objects in XPath,
XSLT, Schematron, etc.
> So I think there would be definite performance benefits (in terms of
> both speed and memory use) in keeping a dictionary of names -> string
> values instead of names -> nodes.

I did that in older versions of minidom. Then I implemented namespaces
and it started to get really hairy. You need to be able to look things
up by tagname and localname/URI prefix. Then you need to be able to get
from tagnames to localname/URI and back in case you need to delete or
update an attribute. The right hand side become some kind of a tuple
that you need to split and you are almost back to objects again...ugh.

In general, namespaces make XML a lot harder to work with. A lot harder.

So I eventually backed it out on the argument that getting it right but
inefficient for Python 1.6 was more important than being tricky but
efficient. The idea is still good but it requires more thought.
> Attribute nodes could be lazily instantiated when someone calls
> getAttributeNode. If we want to support entity references inside
> attributes we can do this by using lists in the dictionary for those
> cases instead of strings. Most likely this would be used in much less
> than 1% of the cases and I wouldn't complain if we decided not to
> support this stuff at all.

Few of the parsers generate entity reference events in attributes...we
certainly don't support this now.

 Paul Prescod  - ISOGEN Consulting Engineer speaking for himself
Floggings will continue until morale improves.