David, I've made a fix. It's a cheap fix. It's basically says: Let's treat the builtin type `xs:NCName` as if it's an `xs:string`, which I believe is the right thing to do.
I've pushed this patch to Bitbucket (https://bitbucket.org/dkuhlman/generateds). Is that convenient for you? If not, let me know and I'll send you a patch or something. Also, I did a little checking at https://www.w3.org/TR/xmlschema-0/#SimpleTypeFacets. It appears to me that `xs:QName` should be handled the same way. So, I made that modification, also. This fix seems to work. It passes my tests. Please let me know if it fixes things for you. Maybe, in the future, we should ask whether there is something more that gDS should do ... maybe something in the way of more restrictive checking on the value. Or, maybe not. What do you think? I think this fix is good enough for now. Adding special processing for `xs:NCName`, `xs:QName`, and possibly others (over and above what gDS does now for `xs:string`) can be left for another day. It's an enhancement, after all. Or, maybe we do not want to add that extra processing; maybe some use cases would break if we did. Sorry. Just muttering to myself, I guess. Also, I need to investigate whether there are some additional basic types that gDS should also handle. Thanks again, if I did not already thank you, for reporting this issue. Dave On Tue, Sep 17, 2019 at 10:13:05PM +0000, David Milner wrote: > Dave > > I am working with an XSD containing the following complexType which seems to > be compliant (I've validated the code). However, the code generated has a > problem in that it assigns the obj_ variable in buildChildren() method a > value of None which, as expected, causes problems. See generated code after > the type definition. > > What is wrong with the type definition? > > <xs:complexType name="where-type"> > <xs:sequence> > <xs:element name="weight" type="weight-type" minOccurs="1"/> > <xs:choice minOccurs="0" maxOccurs="unbounded"> > <xs:element name="scope"> > <xs:simpleType> > <xs:restriction base="xs:NCName"> > <xs:enumeration value="national"/> > <xs:enumeration value="local"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > <xs:choice> > <xs:element name="type"> > <xs:simpleType> > <xs:restriction base="xs:NCName"> > <xs:enumeration value="broadcast"/> > <xs:enumeration value="cable"/> > <xs:enumeration value="syndicated"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > <xs:element name="network" type="xs:string"/> > <xs:element name="station" type="xs:NCName"/> > <xs:element name="syndicator" type="xs:NCName"/> > </xs:choice> > </xs:choice> > </xs:sequence> > </xs:complexType> > > def buildChildren(self, child_, node, nodeName_, fromsubclass_=False): > if nodeName_ == 'weight': > value_ = child_.text > value_ = self.gds_parse_string(value_, node, 'weight') > value_ = self.gds_validate_string(value_, node, 'weight') > self.weight = value_ > self.weight_nsprefix_ = child_.prefix > # validate type weight-type > self.validate_weight_type(self.weight) > elif nodeName_ == 'scope': > obj_ = None <<<<<<<<<< > problem line > self.scope.append(obj_) > obj_.original_tagname_ = 'scope' > # validate type scopeType > self.validate_scopeType(self.scope[-1]) > elif nodeName_ == 'type': > obj_ = None <<<<<<<<< > problem > self.type_ = obj_ > obj_.original_tagname_ = 'type' > # validate type typeType > self.validate_typeType(self.type_) > > > All suggestions would be appreciate. > > TIA, > David Milner -- Dave Kuhlman http://www.davekuhlman.org _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users