[lxml-dev] Issues with objectify.ObjectifiedElement: assignment, attribute handling, and documentation

Michael Pechal Michael.Pechal at silabs.com
Mon Oct 8 22:55:33 CEST 2007


Holger,

> Note that the foo attribute remains intact, whilst the py:pytype gets
> corrected to s.th. that fits the element value.

[MP] Thanks for your suggestion.  I will follow Stefan's advice and
create separate elements versus using the attribute list.  Thus, I would
have the following structure in my codec.xml file:

codec (TREE)
    reg_config (TREE)
        filter_type (TREE)
            value (int)
            desc (str)
            apply (bool)
            default (int)

This should be faster and cleaner, as I am not abusing the attribute
list.  I also don't have to worry about attribute type conversions,
since all attributes are strings.  I can access the pyval property, so
no conversion is required in my data handler accessor methods.

Phase one involves translating everything into XML (currently custom
data classes with cPickling).  Phase two entails developing an XSD file
to validate the XML.  I imagine the scheme validation will be cleaner
with the separate elements versus the bloated attribute list. 

I have a better understanding of the spirit of lxml, but I have much to
learn regarding XML and XSLT in general.  I will perform more background
reading before troubling this list again with basic questions.  :)


> Regarding your example, explicitly setting _xsi="int" gives

> >>> msg.a = objectify.DataElement(8, _xsi="int")
> >>> print objectify.dump(msg)
> msg = None [ObjectifiedElement]
>    a = 8 [IntElement]
>      * py:pytype = 'int'
>      * xsi:type = 'xsd:int'
> >>>

[MP] Thanks for the clarification.  I need to use _xsi="int".  I will
review the XML schema link that you provided.


Regards,
Michael

This email and any attachments thereto may contain private, confidential, 
and privileged material for the sole use of the intended recipient. Any 
review, copying, or distribution of this email (or any attachments thereto) 
by others is strictly prohibited. If you are not the intended recipient, 
please contact the sender immediately and permanently delete the original 
and any copies of this email and any attachments thereto.



More information about the lxml-dev mailing list