Bing,
Here is a better fix. The fix that I sent yesterday ignored
attributes whose name was the same as the name of an enclosing
attributeGroup. That was wrong.
I expanded and then studied that XML schema you gave me (csx.xsd).
It contains things like the following:
<xs:attributeGroup name="src">
<xs:attribute name="src" type="xs:anyURI"/>
</xs:attributeGroup>
I don't know why the schema authors did it that way rather than
referring to attribute "src" directly. They may have their reasons.
Or, perhaps the tools they used to write this schema generates this
kind of construction for them.
At any rate, we need to include and generate code for attribute
"src" and avoid the infinite recursion. Yesterday's patch avoided
the infinite recursion, but ignored attribute "src".
For an example of where this is relevant, you can look at class
"share" in the generated module.
A patch against version 2.22a is attached. But, you likely will
prefer to get the latest revision from Bitbucket. It contains this
patch. See: https://bitbucket.org/dkuhlman/generateds
Hope this helps. Let me know whether it works or has problems.
Dave
--
Dave Kuhlman
http://www.davekuhlman.org
diff -r 4610927d9a2c generateDS.py
--- a/generateDS.py Mon Apr 11 19:34:44 2016 -0700
+++ b/generateDS.py Thu Apr 21 13:24:00 2016 -0700
@@ -202,7 +202,7 @@
# Do not modify the following VERSION comments.
# Used by updateversion.py.
##VERSION##
-VERSION = '2.22a'
+VERSION = '2.22b'
##VERSION##
if sys.version_info.major == 2:
@@ -1235,16 +1235,22 @@
if key is not None:
attrGroup = AttributeGroups[key]
for name in attrGroup.getKeys():
- if (name in AttributeGroups or
- strip_namespace(name) in AttributeGroups):
+ group = attrGroup.get(name)
+ # If group is none, then it's an attributeGroup,
+ # not an attribute.
+ # Therefore, we might need to follow it recursively.
+ if (group is None and
+ (name in AttributeGroups or
+ strip_namespace(name) in AttributeGroups)):
self.replace_attributeGroup_names_1(name)
else:
attr = attrGroup.get(name)
self.attributeDefs[name] = attr
self.attributeDefsList.append(name)
else:
- err_msg('*** Error. attributeGroup %s not defined.\n' % (
- groupName, ))
+ err_msg('*** Error. Element %s attributeGroup %s '
+ 'not defined.\n' % (
+ self.getName(), groupName, ))
def __str__(self):
s1 = '<XschemaElement name: "%s" type: "%s">' % \
@@ -3748,6 +3754,7 @@
name = mapName(name)
else:
name = mappedName
+ name = cleanupName(name)
s1 = " self.%s.append(obj_)\n" % (name, )
else:
substitutionGroup = child.getAttrs().get('substitutionGroup')
@@ -3756,6 +3763,7 @@
name = mapName(name)
else:
name = mapName(headName)
+ name = cleanupName(name)
s1 = " self.%s = obj_\n" % (name, )
wrt(s1)
wrt(" obj_.original_tagname_ = '%s'\n" % (origName, ))
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users