> Subject: empty output > From: Dayang Abang Ibrahim <d.h.abang-ibra...@newcastle.ac.uk> > To: "dkuhl...@rexx.com" <dkuhl...@rexx.com> > > Hi Dave, > > I have attended a workshop and the participants have presented > several output in xml document. > > I am interested to use the presented XML schema and the XML > document with generateDS.py to create python classes (Both xsd and > xml documents were written by others) > > The generateDS.py can generate the python classes from the xsd > file. > > However, when I test the xml document against the generated python > class, it only gives the following output: > > <?xml version="1.0" ? > <opm:ProcessId > > > > </opm:ProcessId> > > > What are the possibilities that may cause this output? Could it be > the way the data is presented in the XML instance document is > different than the xsd?
Dayang - Good to hear from you. The problem is that generateDS.py does not know which element is the root element in the XML instance document. In the instance document that you sent me (OPMGraph-query1.xml), the root (top-most) element is opm:opmGraph which is implement (in the generated code) by class OPMGraph. But, generateDS.py does not know that it is the root element, because the definition of that element is buried down in the middle of the XML Schema definition (opmsc.xsd). By default, generateDS.py assumes that the top-most element definition in the schema will be the root element in the instance documents. You can override this with the --root-element command line option. So, you can fix this in either of two ways. Either (1) move the definition of element OPMGraph up near the top of the schema or (2) add the --root-element command line flag. To use the command line flag, add "--root-element=OPMGraph" the command that you use to generate the Python bindings. For example, I used: $ generateDS.py -f --super=tmp1sup -o tmp1sup.py -s tmp1sub.py \ --member-specs=dict --root-element=OPMGraph opmsc.xsd After generating with the --root-element command line flag, I was able to parse and export OPMGraph-query1.xml. I have attached the .py files I generated. [omitted on copy sent to generateds-users] The advantage to using the --root-element command line flag is that you will not need to modify the schema and you will not need to remember to make the same modification if and when you get an update to the schema. One point about the XML Schema you sent. opmsc.xsd defines several elements whose name is "value", but does not define an element type "value". I believe that value should have type "xs:string", but I'm just guessing. Perhaps it should be: <xs:complexType name="Artifact"> <xs:sequence> <xs:element name="value" type="xs:string"/> <xs:element name="account" minOccurs="0" maxOccurs="unbounded" type="opm:AccountId"/> </xs:sequence> <xs:attribute name="id" type="xs:ID"/> </xs:complexType> instead of: <xs:complexType name="Artifact"> <xs:sequence> <xs:element name="value"/> <xs:element name="account" minOccurs="0" maxOccurs="unbounded" type="opm:AccountId"/> </xs:sequence> <xs:attribute name="id" type="xs:ID"/> </xs:complexType> > > I have attached the xsd and the xml file in this email for your > reference. Could you help to advise me on this matter? > > Many thanks in advance, You are welcome. Hope this helps. Let me know how it goes. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users