[Checkins] SVN: Sandbox/nadako/zcmlschema/src/zcmlschema/generate.py define complexTypes in the elements themselves, prepare to work with subdirectives
Dan Korostelev
nadako at gmail.com
Tue Nov 18 15:15:21 EST 2008
Log message for revision 93098:
define complexTypes in the elements themselves, prepare to work with subdirectives
Changed:
U Sandbox/nadako/zcmlschema/src/zcmlschema/generate.py
-=-
Modified: Sandbox/nadako/zcmlschema/src/zcmlschema/generate.py
===================================================================
--- Sandbox/nadako/zcmlschema/src/zcmlschema/generate.py 2008-11-18 19:20:07 UTC (rev 93097)
+++ Sandbox/nadako/zcmlschema/src/zcmlschema/generate.py 2008-11-18 20:15:21 UTC (rev 93098)
@@ -26,8 +26,6 @@
common = namespaces.pop('', ())
for ns, directives in namespaces.items():
- seenDirectives = set()
-
filename = quoteNS(ns) + '.xsd'
file = open(filename, 'w')
doc = dom.createDocument('http://www.w3.org/2001/XMLSchema', 'schema', None)
@@ -40,33 +38,29 @@
directives.update(common)
for directive in directives:
- schema = directives[directive][0]
- type_name = '%s.%s' % (schema.__module__, schema.__name__)
+ el = doc.createElement('element')
+ el.setAttribute('name', directive)
- if type_name not in seenDirectives:
- type = doc.createElement('complexType')
- type.setAttribute('name', type_name)
+ type = doc.createElement('complexType')
- if schema.__doc__:
- addDoc(doc, type, schema.__doc__)
+ schema = directives[directive][0]
- for name, field in getFieldsInOrder(schema):
- if name.endswith('_') and iskeyword(name[:-1]):
- name = name[:-1]
- attr = doc.createElement('attribute')
- attr.setAttribute('name', name)
- attr.setAttribute('type', 'string')
+ if schema.__doc__:
+ addDoc(doc, type, schema.__doc__)
- if field.__doc__:
- addDoc(doc, attr, field.__doc__)
+ for name, field in getFieldsInOrder(schema):
+ if name.endswith('_') and iskeyword(name[:-1]):
+ name = name[:-1]
+ attr = doc.createElement('attribute')
+ attr.setAttribute('name', name)
+ attr.setAttribute('type', 'string')
- type.appendChild(attr)
- root.appendChild(type)
- seenDirectives.add(type_name)
+ if field.__doc__:
+ addDoc(doc, attr, field.__doc__)
- el = doc.createElement('element')
- el.setAttribute('name', directive)
- el.setAttribute('type', 'target:' + type_name)
+ type.appendChild(attr)
+
+ el.appendChild(type)
root.appendChild(el)
doc.writexml(file, addindent='\t', newl='\n')
More information about the Checkins
mailing list