[lxml-dev] objectify.deannotate: call to etree.cleanup_namespaces in 2.1beta

Hi, I have a usecase where I need to deannotate an objectified tree and then manually set py:pytype or xsi:type attributes. However, this seems to be getting difficult with 2.1beta as deannotate wipes out all nsmap information with its call to cleanup_namespaces(), and I cannot set a namespaced attribute through <elt>.set(...) Maybe I'm missing something and there's a convenient way to do this? If not, could we make the call to cleanup_namespaces optional (defaults to True) in deannotate()? Holger -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/?mc=sv_ext_mf@gmx

Hi,
A namespaced attribute value like "xsd:string". It is easy to set a ns-qualified attribute using Clark notation, as anywhere in lxml.
I'll remove it, then. Rationale: lxml does a good job of keeping namespace declarations clean when adding elements to a tree anyway, so with objectify's default nsmap namespace declarations concerning xsi:type and py:pytype are usually located at the root element only. Anyone who needs a real clean document can still conveniently call etree.cleanup_namespaces() after deannotate(). Holger -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx

$ svn diff -r55702:56199 src/lxml/lxml.objectify.pyx Index: src/lxml/lxml.objectify.pyx =================================================================== --- src/lxml/lxml.objectify.pyx (revision 55702) +++ src/lxml/lxml.objectify.pyx (revision 56199) @@ -1752,7 +1752,6 @@ cetree.delAttributeFromNsName( c_node, _XML_SCHEMA_INSTANCE_NS, "type") tree.END_FOR_EACH_ELEMENT_FROM(c_node) - etree.cleanup_namespaces(element) ################################################################################ -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx

Hi,
A namespaced attribute value like "xsd:string". It is easy to set a ns-qualified attribute using Clark notation, as anywhere in lxml.
I'll remove it, then. Rationale: lxml does a good job of keeping namespace declarations clean when adding elements to a tree anyway, so with objectify's default nsmap namespace declarations concerning xsi:type and py:pytype are usually located at the root element only. Anyone who needs a real clean document can still conveniently call etree.cleanup_namespaces() after deannotate(). Holger -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx

$ svn diff -r55702:56199 src/lxml/lxml.objectify.pyx Index: src/lxml/lxml.objectify.pyx =================================================================== --- src/lxml/lxml.objectify.pyx (revision 55702) +++ src/lxml/lxml.objectify.pyx (revision 56199) @@ -1752,7 +1752,6 @@ cetree.delAttributeFromNsName( c_node, _XML_SCHEMA_INSTANCE_NS, "type") tree.END_FOR_EACH_ELEMENT_FROM(c_node) - etree.cleanup_namespaces(element) ################################################################################ -- GMX startet ShortView.de. Hier findest Du Leute mit Deinen Interessen! Jetzt dabei sein: http://www.shortview.de/wasistshortview.php?mc=sv_ext_mf@gmx
participants (3)
-
Holger Joukl
-
jholg@gmx.de
-
Stefan Behnel