>From: Amal Khailtash >Sent: Fri, August 27, 2010 10:43:23 AM > > Dave, > > Thanks for putting more time on this. I am in no rush. Take your > time and do what you have to do. > > I knew I needed to set a variable, but being a python rookie, I > didn't know this variable PYTHONPATH. Thanks for mentioning that.
Amal - Good. So now, being able to put configuration values in a module named generateds_config.py and placing it where generateDS.py can import it seems like a reasonable way to go, don't you think. > > In the meantime, I have created a number of xml example files and > also a main.py file that uses your suggested scheme. The > abstractor class is now created, Good. > but I still see a few problems. > One is that there is no component class even though component.xsd > specifies: > > <xs:element name="component" type="spirit:componentType"> Well, I think the above definition is saying that there can be a top-level element whose tag is "component" and whose attributes and content is defined by the complexType "componentType". So your code (below) correctly creates an instance of componentType. And, it seems to me, generateDS.py *should* generate class componentType, *not* class component. > > I think if this problem is solved, I almost have all the classes > for these schemas and I might be able to use the following method > that you use in the generated python files: > > rootTag, rootClass = get_root_tag(rootNode) > if rootClass is None: > print "Cannot find the rootClass!" > sys.exit(1) > rootObject = rootClass.factory() > rootObject.build(rootNode) > > This way, I can construct the object and have access to the rootTag > as well. This fails for component, because no component class is > created! And I use the following and use componentType instead in > the meantime: > > rootTag = Tag_pattern_.match(rootNode.tag).groups()[-1] > if rootTag == 'abstractionDefinition': > rootClass = IP_XACT_Document.abstractionDefinition > elifrootTag == 'abstractor': > rootClass = IP_XACT_Document.abstractor > elifrootTag == 'busDefinition': > rootClass = IP_XACT_Document.busDefinition > elifrootTag == 'component': > # rootClass = IP_XACT_Document.component # this should work! > rootClass = IP_XACT_Document.componentType I think that creating an instance of componentType is the correct thing to do. > elifrootTag == 'design': > rootClass = IP_XACT_Document.design > elifrootTag == 'generatorChain': > rootClass = IP_XACT_Document.generatorChain > elifrootTag == 'designConfiguration': > rootClass = IP_XACT_Document.designConfiguration > else: > print 'Unknow top-level element "', rootTag, '"' > sys.exit(1) > > rootObject = rootClass.factory() > rootObject.build(rootNode) > > I have attached the main.py, the generated classes from index.xsd > (IP_XACT_Document.py), the schemas and sample possible root > elements (busDefinition, abstractDefinition, component, > anbstractor, design, generatorChain, and designConfiguration). Thanks for these samples. They'll be very helpful for doing testing. > > Thanks for looking into this and you've done a great job with this > tool. It is very useful for what I want and other than the .NET > XSD tool, and another one that creates very complex C++ classes, I > have not seen any other tool. > You are welcome, and thank for the compliment. I've found a few special cases that the new version of process_includes.py did not handle correctly and have fixed them. I've identified one more problem. I hope to fix that, to do a little more testing, and to create a unit test. Hopefully, I will have a new version for you sometime next week. Thanks again for your comments, for the reports, and for the sample files. It all makes things easier for me. More next week. - Dave -- Dave Kuhlman http://www.rexx.com/~dkuhlman ------------------------------------------------------------------------------ Sell apps to millions through the Intel(R) Atom(Tm) Developer Program Be part of this innovative community and reach millions of netbook users worldwide. Take advantage of special opportunities to increase revenue and speed time-to-market. Join now, and jumpstart your future. http://p.sf.net/sfu/intel-atom-d2d _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users