Andrii, Seems like we could make one of two possible changes:
1. The validator method should do that conversion to integer when it performs it's test. So, the test should like this: if int(value) < 1900: instead of: if value < 1900: 2. Or, maybe this would be better: if value < '1900': The reason that I suggest this second fix is because we should be able to handle xs:gYearMonth types in addition to xs:gYear types. For example: if value < '1900-01': That would work, don't you think? Does that seem reasonable to you? And, I believe that will do the right thing on both Python 2 and Python 3. I'll need to also change the code generation for maxInclusive, minExclusive, etc. I'll do some more testing and then will push this change to the repository at Bitbucket, unless I hear a squawk from you. And, thanks for alerting me to this. Dave On Mon, May 13, 2019 at 03:18:11PM +0100, Andrii Iudin wrote: > Dear Dave, > > We are in a process of moving to Python 3 and have stumbled upon the > following problem. We have a field defined as > <xs:element name="year" minOccurs="0"> > <xs:simpleType> > <xs:restriction base="xs:gYear"> > <xs:minInclusive value="1900"/> > </xs:restriction> > </xs:simpleType> > </xs:element> > > The generated code for it is > def validate_yearType(self, value): > # Validate type yearType, a restriction on xs:gYear. > if value is not None and Validate_simpletypes_: > if value < 1900: > warnings_.warn('Value "%(value)s" does not match xsd > minInclusive restriction on yearType' % {"value" : value} ) > > Which is fine in Python 2. However, when an XML file that contains > <year>2017</year> > > is being processed in Python 3 the following error occurs: > File "path/empiar.py", line 3784, in validate_yearType1 > if value < 1900: > TypeError: '<' not supported between instances of 'str' and 'int' > > Please could you advise on the way to solve this? > > Many thanks and best regards, > Andrii > > > _______________________________________________ > generateds-users mailing list > generateds-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/generateds-users -- Dave Kuhlman http://www.davekuhlman.org _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users