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

Michael Pechal Michael.Pechal at silabs.com
Tue Oct 9 00:38:15 CEST 2007


Stefan,

> Doesn't tostring() or ElementTree(root).write() do what you want? I
don't
> see why you would go through pickling here...
> http://effbot.org/elementtree/elementtree-elementtree.htm

They work very well!  What I was trying to say is that I currently use
custom python classes that are persisted via cPickle.  Phase one
involves replacing the data model with lxml.objectify and all of its
superior power.  So, goodbye cPickled data classes and hello
lxml.objectify!  In the past, I have leveraged cPickle, ConfigParser, or
custom parser.  I have wanted to leverage XML for some time but the
learning curve is steep.  Now lxml.objectify has come to my rescue.

My tool is based on MVC design.  I have converted the data model to an
objectified tree and I have a unittest wrapper to exercise the data
model.  Before I update the controller methods for tree access, I wanted
to finalize the XML structure.  I just need to refactor the data model
and "do it right" with more elements versus hacking the attribute list.
Then, phase one will be complete.

> > Phase two entails developing an XSD file to validate the XML.

> Unless you are very firm with XML Schema and/or have good tool
support, I
> generally suggest writing a RelaxNG schema instead (preferably in the
> "compact syntax" aka RNC), which is easy to write, read and understand
and
> is well supported by lxml/libxml2. It also supports the XSD datatypes
and
> can be translated into an XML Schema via tools like trang.

Thanks for the advice.  I will explore RelaxNG schema first.  We are out
of licenses for Altova XMLSpy 2007 and it is pricy!  I found Editix
(http://www.editix.com/) for $85.  It is cross-platform (*nix, OS X and
Windows).  The documentation lists Schema Generator (DTD, W3C XML
Schema, XML Relax NG) from XML documents.  When I am serious about
schema work, I will try out the shareware version.

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