> From: Rochanglien Infimate
> Sent: Thursday, September 3, 2009 12:04:14 AM
>
> Hi Dave,
>               I have a problem when i issue a generateDS command on the
> xsd available at
> http://communities.vmware.com/static/vcloudapi/vcloud-api-v0.8-xsd-files.zip.
> I am using python2.4 + pyXML + lxml for xsd generation. I have tried
> this in python2.5 + lxml but i still get the following traceback
> when i run python generateDS.py -o vcloud.py -s vcloud.py vcloud/vcloud.xsd
>
> Traceback (most recent call last):
> File "generateDS.py", line 4404, in ?
> main()

[snip]

> File "generateDS.py", line 1189, in startElement
> self.stack[-1].unionOf.append(member)
> AttributeError: XschemaElement instance has no attribute 'unionOf'
>

Chang -

Good to hear from you.

Attached is a patch.  It's a diff against version 1.18e.  With this
fix, I was able to parse and generate files from vcloud.xsd.  I run
it with the following command:

    $ ./generateDS.py -f --super=tmp1sup -o tmp1sup.py -s tmp1sub.py vcloud.xsd

*But*, the generated code has a problem -- the vcloud schema
uses a built-in type called xs:anySimpleType.  generateDS.py
does not handle that.  So, I'll try to get back to you on that
problem, tomorrow.

If you do try generating code using this patch,
please let me know whether it works for you, or if you have
additional issues.

More tomorrow, I hope.

- Dave

 -- 


Dave Kuhlman
http://www.rexx.com/~dkuhlman
=== modified file 'Generateds/Generateds/generateDS.py'
--- Generateds/Generateds/generateDS.py	2009-09-03 18:44:27 +0000
+++ Generateds/Generateds/generateDS.py	2009-09-03 22:23:21 +0000
@@ -1182,7 +1182,9 @@
         elif name == UnionType:
             # Union types are only used with a parent simpleType and we want
             # the parent to know what it's a union of.
-            if attrs.has_key('memberTypes'):
+            parentelement = self.stack[-1]
+            if (isinstance(parentelement, SimpleTypeElement) and 
+                attrs.has_key('memberTypes')):
                 for member in attrs['memberTypes'].split(" "):
                     self.stack[-1].unionOf.append(member)
         elif name == WhiteSpaceType and self.inRestrictionType:
@@ -1217,8 +1219,9 @@
         elif name == ElementType or (name == ComplexTypeType and self.stack[-1].complexType):
             self.inElement = 0
             self.inNonanonymousComplexType = 0
-            element = self.stack.pop()
-            self.stack[-1].addChild(element)
+            if len(self.stack) >= 2:
+                element = self.stack.pop()
+                self.stack[-1].addChild(element)
         elif name == ComplexTypeType:
             self.inComplexType = 0
         elif name == SequenceType:
@@ -4219,6 +4222,13 @@
 ##         outfile.seek(0)
 ##         print '-' * 50
 ##         #
+##         #
+##         content = outfile.read()
+##         tmpfile = open('tmp.xsd', 'w')
+##         tmpfile.write(content)
+##         tmpfile.close()
+##         outfile.seek(0)
+##         #
         infile = outfile
     parser.parse(infile)
     root = dh.getRoot()

------------------------------------------------------------------------------
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

Reply via email to