开发者

Can generateDS be used like xsd.exe

开发者 https://www.devze.com 2022-12-21 15:08 出处:网络
Can I u开发者_开发百科se generateDS.py in python in a similar way that I would use xsd.exe to create C# classes from xsd?

Can I u开发者_开发百科se generateDS.py in python in a similar way that I would use xsd.exe to create C# classes from xsd?

Basically, given an xsd schema I want to create a data structure, in python, fill its data in, and then render it into an xml string.

perhaps pyXSD is better?

oh, and yes, I'm a python newbie


generateDS did exactly what I wanted it to, a way to deal with a object graph of data, rather than a node graph

ran

python generateDS.py -o MedicationDS.py medication.xsd

gave me a python Class I could instantiate and populate with data, then render to a stream.

medObj = MedicationDS.Medication.factory()
medObj.set_dateStarted('2010-01-01')
medObj.set_dateStopped('2010-02-02')
medObj.set_reasonStopped('hurt my brain')
brandNameObj = MedicationDS.CodedValue.factory()
brandNameObj.set_abbrev('aspirin')
brandNameObj.set_value('aspirin')
medObj.set_brandName(brandNameObj)

xmlStr=StringIO()
medObj.export(xmlStr, 0)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号