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 - 

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?
------------------------------------------------------------------------------
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to