Generating python data structtures from xml (again)
It is seems this question was asked before: i found discussion here: https://mailman-mail5.webfaction.com/pipermail/lxml/2008-January/003243.html The question is: how can i generate python data structure with lxml.objectify and XML Schema without manually specifying attributes or types in xml. It seems this was asked before and only possible to do this with AttributeBasedElementClassLookup and specifying attributes in xml. Is this still so in current development version? Should i abandon any hope this will be implemented? -- -------------------------------------------- Турнаев Евгений Викторович +7 906 875 09 43 --------------------------------------------
Hi,
It is seems this question was asked before: i found discussion here: https://mailman-mail5.webfaction.com/pipermail/lxml/2008-January/003243.html
The question is: how can i generate python data structure with lxml.objectify and XML Schema without manually specifying attributes or types in xml. It seems this was asked before and only possible to do this with AttributeBasedElementClassLookup and specifying attributes in xml. Is this still so in current development version? Should i abandon any hope this will be implemented?
Well, if you mean "is there a 'typifier' that automatically annotates lxml.objectify trees from an XML Schema *today*?" the answer is no, not that I know of.
From your post it is unclear to me, though, if your use case depends on such a thing, e.g. for custom element lookup. Of course, lxml.objectify is perfectly usable without caring much about a Schema.
Holger -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
Holger, 12.10.2011 13:00:
It is seems this question was asked before: i found discussion here: https://mailman-mail5.webfaction.com/pipermail/lxml/2008-January/003243.html
The question is: how can i generate python data structure with lxml.objectify and XML Schema without manually specifying attributes or types in xml. It seems this was asked before and only possible to do this with AttributeBasedElementClassLookup and specifying attributes in xml. Is this still so in current development version?
Depends on your specific use case and data format. Larger formats will likely benefit more from the namespace based lookup, and the existing typing heuristic tends to work pretty well in practice.
Should i abandon any hope this will be implemented?
Well, if you mean "is there a 'typifier' that automatically annotates lxml.objectify trees from an XML Schema *today*?" the answer is no, not that I know of.
In general, XML Schema is way too complicated to solve this completely. And the benefit tends to be way too small to invest the time.
From your post it is unclear to me, though, if your use case depends on such a thing, e.g. for custom element lookup. Of course, lxml.objectify is perfectly usable without caring much about a Schema.
Agreed. I personally consider XML Schema a huge, unwieldy obstacle that just keeps people from getting XML work done. It's worth some additional effort if that allows you to avoid dealing with it. Stefan
participants (3)
-
Evgeny Turnaev
-
jholg@gmx.de
-
Stefan Behnel