Hi Dave,
Thank you for the new version. Unfortunately it doesn't seem to work for me
yet. I have the following definition:
<xs:element name="MetaConstruct">
<xs:complexType>
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="dataType" type="dataTypeEnum" />
</xs:complexType>
</xs:element>
As you can see, this type can not have any children. However, the export
function it generates does seem to want to export children:
def export(self, outfile, level, namespace_='', name_='MetaConstruct'):
showIndent(outfile, level)
outfile.write('<%s%s' % (namespace_, name_))
self.exportAttributes(outfile, level, namespace_,
name_='MetaConstruct')
outfile.write('>\n')
self.exportChildren(outfile, level + 1, namespace_, name_)
outfile.write('</%s%s>\n' % (namespace_, name_))
I've looked through generateDS's code, and I found the following (line 1487):
elif childCount == 0:
s1 = " outfile.write('>\\n')\n"
outfile.write(s1)
s1 = " self.exportChildren(outfile, level + 1, namespace_,
name_)\n"
outfile.write(s1)
s1 = " outfile.write('</%s%s>\\n' % (namespace_, name_))\n"
outfile.write(s1)
I was wondering if this shouldn't say:
elif childCount == 0:
s1 = " outfile.write(' />\\n')\n"
outfile.write(s1)
Because you know it doesn't allow any children. Then you don't need to check
for them.
Regards,
Vincent
> -----Original Message-----
> From: Dave Kuhlman [mailto:[email protected]]
> Sent: dinsdag 17 februari 2009 0:39
> To: Vincent van Beveren
> Cc: [email protected]
> Subject: Re: [Generateds-users] FW: Couple of issues writing XML
>
> Vincent -
>
> I believe that I've solved the problem of elements with empty
> content, although there might be a few corner cases that are not
> handled correctly.
>
> I've attached a version of generateDS.py that has these changes:
>
> Version 1.16a (2/16/2009)
> * Generated export methods now check for empty content and
> write out <xx ... /> rather than <xx ...></xx> if empty.
> * All generated constructors (__init__()) now initialize
> instance variables to None.
> * Generated export methods now check for None before attempting
> to write out attributes and children.
> * More consistent use of direct access to instance variables
> rather than calling getter methods with a class, that is
> use of self.xxx rather than self.get_xxx().
>
> The reason for the change to initializing instance variables to None and
> checking for None before using an instance variable is (1) that XMLBeans
> does it that way, I believe, and (2) this will enable a user of the
> generated code to determine whether an instance variable is set to a
> default value or is uninitialized.
>
> This change does require users to add some code that does the
> check for None.
>
> Could you give it a try. It passes my tests. If it passes your
> testing (and testing done by anyone else that tries it), I'll
> upload a new version.
>
> - Dave
>
> --
>
>
> Dave Kuhlman
> http://www.rexx.com/~dkuhlman
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
generateds-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/generateds-users