[Checkins] SVN: Sandbox/nadako/zcmlschema/src/zcmlschema/generate.py add prefixes

Dan Korostelev nadako at gmail.com
Tue Nov 18 15:53:14 EST 2008


Log message for revision 93103:
  add prefixes

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 20:52:28 UTC (rev 93102)
+++ Sandbox/nadako/zcmlschema/src/zcmlschema/generate.py	2008-11-18 20:53:13 UTC (rev 93103)
@@ -6,15 +6,17 @@
 from zope.configuration.docutils import makeDocStructures
 from zope.schema import getFieldsInOrder
 
+xsns = 'http://www.w3.org/2001/XMLSchema'
+
 def quoteNS(ns):
     ns = ns.replace(':', '_co_')
     ns = ns.replace('/', '_sl_')
     return ns
 
 def addDoc(doc, element, text):
-    annotation = doc.createElement('annotation')
+    annotation = doc.createElement('xs:annotation')
     element.appendChild(annotation)
-    documentation = doc.createElement('documentation')
+    documentation = doc.createElement('xs:documentation')
     annotation.appendChild(documentation)
     documentation.appendChild(doc.createTextNode(text))
 
@@ -28,20 +30,19 @@
     for ns, directives in namespaces.items():
         filename = quoteNS(ns) + '.xsd'
         file = open(filename, 'w')
-        doc = dom.createDocument('http://www.w3.org/2001/XMLSchema', 'schema', None)
+        doc = dom.createDocument(xsns, 'xs:schema', None)
         root = doc.documentElement
 
-        root.setAttribute('xmlns', 'http://www.w3.org/2001/XMLSchema')
-        root.setAttribute('targetNamespace', ns)
-        root.setAttribute('xmlns:target', ns)
+        root.setAttribute('xmlns:xs', xsns)
+        root.setAttribute('xs:targetNamespace', ns)
 
         directives.update(common)
 
         for directive in directives:
-            el = doc.createElement('element')
+            el = doc.createElement('xs:element')
             el.setAttribute('name', directive)
 
-            type = doc.createElement('complexType')
+            type = doc.createElement('xs:complexType')
 
             schema = directives[directive][0]
 
@@ -51,7 +52,7 @@
             for name, field in getFieldsInOrder(schema):
                 if name.endswith('_') and iskeyword(name[:-1]):
                     name = name[:-1]
-                attr = doc.createElement('attribute')
+                attr = doc.createElement('xs:attribute')
                 attr.setAttribute('name', name)
                 attr.setAttribute('type', 'string')
 



More information about the Checkins mailing list