Open boucman opened 10 years ago
Sorry for the delay on responding - this project desperately needs volunteers. Let us know if you can help.
i'll try to see what I can do, how would you prefer to have this handled ? documentation ? new function ? optional parameter ?
@sorenroug would be better to comment on this. All I have done so far on this project so far is put it back on pypi. If you propose your own solution I could help you test it out at least.
It is possible to deal with namespace collission. There is a qattributes argument that takes a namespace, localname tuple:
from odf import draw
from odf.namespaces import PRESENTATIONNS, DRAWNS
df = draw.Frame(width="476pt", height="404pt",
qattributes={ (PRESENTATIONNS, 'style-name'): 'presstyle',
(DRAWNS, 'style-name'): 'drawstyle' } )
@sorenroug so a documentation patch would be enough in your view ? does that work with Element.setAttrbute too ?
Yes it does. If the attribute name is a tuple, like (PRESENTATIONNS, 'style-name').
I just had some problems with draw:frame and namspaces
this element can have both a presentation:style-name and a draw:style-name attribute. the current Element.setAttribute() function will use the first attribute with the name given (in this case draw:) but there is no easy way to access the other attribute. I had to use Element.setAttrNS which is undocumented and doesn't check the grammar
I looked in the api documentation and that sort of conflicts seem common enough that it needs to be dealt with...
I would suggest adding an optional "namespace= namspace.NAME" parameter to setAttribute, maybe make it mandatory for attributes that have a conflict...