Can generateDS be used like xsd.exe
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)
精彩评论