Edmon
Edmon

Reputation: 4872

Python XML binding

I am designing a reference implementation for EmotionML (W3C's language for machine representation of emotions) in Python and I would like some design suggestions on data types to XML binding (I guess you can say I am crowdsourcing some design ideas).

I would like suggestions and pointers to some design and code of people who might have already done similar. My tendency is to just use Java path I am familiar of creating objects that correspond to the structures of XML and have them translated into DOM.

OO gives me polymorphism but creates a more intricate object structure, where Python is very good about set representation and use of built in collections.

I am looking for possible more elegant approach. Could I define my own non-object structs and interrogate these and translate into DOM?

How would I represent optional, mandatory attributes, elements using lists and dictionaries?

These are all my design thoughts and dilemmas, not per say cries for help.

I could figure these things on my own, so I am truly soliciting mature, benevolent suggestions from experienced Python designers and developers.

Thanks in advance, Edmon

Upvotes: 1

Views: 2316

Answers (2)

Amm Sokun
Amm Sokun

Reputation: 1298

OR you may use generateDS.py which serves the purpose of being an XML binder for Python. Given a scheme definition, it automatically generated the data classes in python and also produces the xml export/import method.

Upvotes: 3

Francis Avila
Francis Avila

Reputation: 31641

Data binding is not very common in the Python world compared to Java or C#. I think this is because Python has so many much better XML APIs that are in use instead of the horrible monstrosity that is the DOM.

Investigate these APIs to see if they meet your needs:

Upvotes: 2

Related Questions