[lxml-dev] annotate, pyannotate, xsiannotate

jholg at gmx.de jholg at gmx.de
Thu Sep 13 10:17:04 CEST 2007


> There's an additional keyword arg keep_tree that lets you preserve
> existing TREE attribute values, if switched on.
> 
> No way. :)
> 
> It doesn't match the existing "ignore_*" parameters and the default is to
> /remove/ the tree annotation when what we want is to /create/ annotations.

Hm, maybe then pyannotate() should rather not default to remove TREE attributes?

> Taking one step back: what was the reason again why we started using TREE
> annotation at all? I mean, it doesn't have any advantage and it currently
> looks like it's getting in the way. Is there a reason that should keep us
> from
> just dropping it? completely? (minus backwards compatibility?)
> 
> I mean, honestly, it's not used and it's even faster to check for children
> than it is to look up the attribute...

It's there to allow for leaf elements to be ObjectifiedElements, rather than ObjectifiedDataElements.
The rules are easy for all other use cases:
- the root has no parent element -> ObjectifiedElement
- any other element with children -> ObjectifiedElement

Things get difficult if you assign leaf elements and actually instantiate the python proxy objects. If no TREE attributes get used, these will end up being "default empty elements", usually string elements.

Also, once having been serialized, there is no way that leaf elements can be recognized as ObjectifiedElements without the help of the TREE attribute. That's the main reason I propose the keep_tree functionality, to make ObjectifiedElement-leaves survive a creation-serialization-parse cycle.

Holger

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the lxml-dev mailing list