On 6.10.2011 3:10, Dave Kuhlman wrote: >> From: Luc Saffre <luc.saf...@gmx.net> >> >> But ServiceRequestType has also an <xs:any> element, and I didn't find >> how I can specify, in the Python code, a value for this. The >> documentation speaks about <xs:anyAttribute>, but not about <xs:any>. >> >> How can I achieve that? Do I need to write a User Methods module? > > OK. I've read a bit about it now. Since xs:any is a wildcard, we'd > have to generate code that can parse/build and export any kind of > complexType and maybe any simpleType too. The generated code would > also have to be able to handle single instances and multiple > instances (maxOccurs="1" and maxOccurs="unbounded"). I suppose you > are right. User Methods might be a way to handle that. Or, maybe a > couple of new methods in GeneratedsSuper class (e.g. gds_build_any > and gds_export_any) and a bit of code wrapped around around calls to > those methods in the buildChildren and exportChildren methods in > classes for complexType elements that contain an xs:any child. > > Give me a day or two to think about it. Maybe I can write a sample > of the code we'd generate, and then we can evaluate it and discuss > it.
Yes, I give you a day or two ;-) And I'll even try to think with you. If you ask me, an <any> element should be treated like any other child element except that there is no type checking and no surrounding tag. User code is responsible for supplying a valid XML string. In my case I'm going to generate that string according to another XSD file (the one specified by ServiceId). Already the instantiator of class ServiceRequestType should change. Currently it is:: def __init__(self, ServiceId=None, Version=None): self.ServiceId = ServiceId self.Version = Version But it should be:: def __init__(self, ServiceId=None, Version=None,any=None): self.ServiceId = ServiceId self.Version = Version self.any = any And then of course new methods get_any and set_any. And e.g. exportChildren should be something like:: def exportChildren(self, outfile, level, namespace_='', name_='ServiceRequestType', fromsubclass_=False): if self.ServiceId is not None: showIndent(outfile, level) outfile.write('<%sServiceId>%s</%sServiceId>\n' % (namespace_,self.gds_format_string(quote_xml( self.ServiceId).encode(ExternalEncoding), input_name='ServiceId'), namespace_)) ... if self.any is not None: showIndent(outfile, level) outfile.write(self.any.encode(ExternalEncoding), input_name='ServiceId'), namespace_)) But these are maybe naive ideas since I have no serious experience and didn't yet dive into your code. Luc ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity and more. Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. http://p.sf.net/sfu/splunk-d2dcopy1 _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users