Hi all,
I slept over my yesterday remrarks about target namspace and I know have a
better understanding of the situation.
I was mixed up because the targetNamspace in the schema has to become the
default namespace of the generated xml (to be validated against). And At some
point I had beleive that was what Andre patch was doing (wich is not).
So here is a patch that add the default namspace in the xml generated by the
export functions.
In this patch file there is also the previous patch I submitted for solving the
issue of the children of an abstarct class not checked.
I had no choice to do that as they were impacting each other.
Cheers,
Guillaume Morin
--- old_generateDS.py 2008-05-29 14:51:02.000000000 -0400
+++ generateDS.py 2008-05-30 11:04:12.000000000 -0400
@@ -1308,25 +1308,20 @@
outfile.write(s1)
s1 = ' showIndent(outfile, level)\n'
outfile.write(s1)
+ s1 = " outfile.write('<%s%s' % (namespace_, name_))\n"
+ outfile.write(s1)
+ s1 = ' addDefaultNamespace(outfile, level)\n'
+ outfile.write(s1)
if len(element.getAttributeDefs()) > 0 or element.getAnyAttribute():
- s1 = " outfile.write('<%s%s' % (namespace_, name_))\n"
- outfile.write(s1)
-
s1 = " self.exportAttributes(outfile, level, name_='%s', namespace_='%s')\n" % \
(element.getName(), namespace)
outfile.write(s1)
- if element.isMixed() or childCount == 0:
- s1 = " outfile.write('>')\n"
- else:
- s1 = " outfile.write('>\\n')\n"
- outfile.write(s1)
+ if element.isMixed() or childCount == 0:
+ s1 = " outfile.write('>')\n"
else:
- if element.isMixed() or childCount == 0:
- s1 = " outfile.write('<%s%s>' % (namespace_, name_))\n"
- else:
- s1 = " outfile.write('<%s%s>\\n' % (namespace_, name_))\n"
- outfile.write(s1)
-
+ s1 = " outfile.write('>\\n')\n"
+ outfile.write(s1)
+
s1 = " self.exportChildren(outfile, level + 1, name_, namespace_)\n"
outfile.write(s1)
if element.isMixed() or childCount == 0:
@@ -2158,6 +2153,13 @@
parent = ElementDict[base]
s1 = " %s.buildChildren(self, child_, nodeName_)\n" % (base, )
outfile.write(s1)
+ else:
+ if base and base in ElementDict and base not in SimpleTypeDict:
+ parent = ElementDict[base]
+ s1 = " elif child_.nodeType == Node.ELEMENT_NODE:\n"
+ outfile.write(s1)
+ s1 = " %s.buildChildren(self, child_, nodeName_)\n" % (base, )
+ outfile.write(s1)
# end generateBuildFn
@@ -3159,10 +3161,6 @@
def get_container(self): return self.container
-#
-# Data representation classes.
-#
-
"""
# Fool (and straighten out) the syntax highlighting.
@@ -3172,6 +3170,25 @@
s1 = TEMPLATE_HEADER % time.ctime()
outfile.write(s1)
+TEMPLATE_NAMESPACE = """\
+#Add the correct default namespace corresponding to the targetNamespace in the schema
+#to the root element when exporting to XML
+def addDefaultNamespace(outfile, level):
+ if level == 0:
+ outfile.write(' xmlns="%s"')
+
+
+#
+# Data representation classes.
+#
+
+"""
+
+def generateDefaultNamespaceHandler(outfile, target_Namespace):
+ s1 = TEMPLATE_NAMESPACE % target_Namespace
+ outfile.write(s1)
+
+
TEMPLATE_MAIN = """\
USAGE_TEXT = \"\"\"
@@ -3762,6 +3779,7 @@
DelayedElements = []
DelayedElements_subclass = []
elements = root.getChildren()
+ generateDefaultNamespaceHandler(outfile, Targetnamespace)
generateFromTree(outfile, prefix, elements, processed)
while 1:
if len(DelayedElements) <= 0:
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users