On Sat, Nov 14, 2015 at 12:25:04AM +0000, Naresh Shenoy wrote:
>    Hi Dave,
>    First off, thanks for this amazing library. I've been using it since a few
>    years for many projects and it works every time! For a new project I'm
>    working on, when I try to create classes out of the below xsd, I got some
>    incorrect output - 

Naresh,

Good to hear from you.  Glad that generateDS.py has been useful and
has mostly been working for you.

The fix that you've made seems good to me.  I'll do some more
testing.  And, I've got a couple of additional fixes to make.  When
I've worked them into generateDS.py I will upload all these fixes.

Thanks for helping to fix this.

Dave

>    XSD
>    ====
>    <?xml version="1.0" encoding="UTF-8"?>
>    <xs:schema xmlns:xs="<text_removed>"
>        targetNamespace="<text_removed>"
>        xmlns:tns="<text_removed>"
>        elementFormDefault="unqualified"
>        xmlns:common="<text_removed>">
>        <xs:simpleType name="matchingStrategy">
>            <xs:restriction base="xs:string">
>                <xs:enumeration value="E" />
>                <xs:enumeration value="P" />
>                <xs:enumeration value="F" />
>            </xs:restriction>
>        </xs:simpleType>
>        <xs:complexType name="Pi">
>            <xs:attribute name="ms"  type="tns:matchingStrategy"
>    default="E"/>
>        </xs:complexType>
>    </xs:schema>
>    Generated File
>    ============
>    --- snip ---
>        def  exportAttributes(self, outfile, level, already_processed,
>    namespace_='tns:', name_='Pi'):
>            if self.ms != E and  'ms'  not  in already_processed:
>                already_processed.add('ms')
>                outfile.write(' ms=%s' % (quote_attrib(self.ms), ))
>    --- snip ---
>    Please note that the double quotes around "E" are missing in the 'if'
>    block. I dug into generateDS.py to check the issue and made the below
>    changes -
>    $ diff venv/bin/generateDS.py generateDS.py 
>    1349,1351c1349,1351
>    <         if self.data_type in SimpleElementDict:
>    <             typeObj = SimpleElementDict[self.data_type]
>    <             typeObjType = typeObj.getRawType()
>    ---
>    >         if strip_namespace(self.data_type) in SimpleTypeDict:
>    >             typeObj = SimpleTypeDict[strip_namespace(self.data_type)]
>    >             typeObjType = typeObj.getBase()
>    The resulting generated file looks like -
>    --- snip ---
>        def  exportAttributes(self, outfile, level, already_processed,
>    namespace_='tns:', name_='Pi'):
>            if self.ms != "E"  and  'ms'  not  in already_processed:
>                already_processed.add('ms')
>                outfile.write(' ms=%s' %
>    (self.gds_format_string(quote_attrib(self.ms).encode(ExternalEncoding),
>    input_name='ms'), ))
>    --- snip ---
>    Do you think this change is correct? If not, could you please let me know
>    if I'm doing something incorrectly?


-- 

Dave Kuhlman
http://www.davekuhlman.org

------------------------------------------------------------------------------
Presto, an open source distributed SQL query engine for big data, initially
developed by Facebook, enables you to easily query your data on Hadoop in a 
more interactive manner. Teradata is also now providing full enterprise
support for Presto. Download a free open source copy now.
http://pubads.g.doubleclick.net/gampad/clk?id=250295911&iu=/4140
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to