> Dear Dave,
> 
> Thank you for looking into this. It seems that comparing with a string 
> is not enough, since on the left side we have a date object. However, it 
> looks like this works:
> if value < datetime_.datetime.strptime('2002-01-01', '%Y-%m-%d').date():
>                  warnings_.warn('Value "%(value)s" does not match xsd 
> minInclusive restriction on dateType' % {"value" : value} )

Andrii,

Thanks for that help.  I'll follow your example code,
above.

I believe I have this solved for xs:date for each of minInclusive,
maxInclusive, minExclusive, and maxExclusive.

Now, I need to fix it for xs:time, xs:datetime, ...

I'll try to have something that you can look at in a day or so.

OK.  I've almost got it.  I'm down to worrying about fractions of a
second for the xs:time and xs:dateTime.  And, I need to do some
testing.  I should be able to send you a fixed version tomorrow.

Dave

> 
> Best regards,
> Andrii
> 
> 
> On 22/04/2016 19:57, Dave Kuhlman wrote:
> > On Fri, Apr 22, 2016 at 04:53:35PM +0100, Andrii Iudin wrote:
> >> Dear Dave and generateDS mailing group,
> >>
> >> After updating to the recent version 2.22a the generated Python source
> >> code for structures appears to have a validation of xs:date elements.
> >> We have one with a facet minInclusive set to '2002-01-01'. The
> >> previously used version 2.13a produced just
> >>       def validate_dateType(self, value):
> >>           # Validate type dateType, a restriction on xs:date.
> >>           pass
> >>
> >> However, now it is defined as
> >>       def validate_dateType(self, value):
> >>           # Validate type dateType, a restriction on xs:date.
> >>           if value is not None and Validate_simpletypes_:
> >>               if value < 2002-01-01:
> >>                   warnings_.warn('Value "%(value)s" does not match xsd
> >> minInclusive restriction on dateType' % {"value" : value} )
> >>
> >> This comparison results in "TypeError: can't compare datetime.date to int".
> > Andrii,
> >
> > Definitely looks and smells like a bug.
> >
> > At the very least, that date in the comparison should have quotes
> > around it.  What if, for the date and time types, we generated the
> > following instead?
> >
> >      if value < "2002-01-01":
> >          warnings_.warn('Value "%(value)s" does not match xsd
> >
> > Would that be what you want?  We'd also have to cover the cases for
> > maxInclusive, minExclusive, and maxExclusive.
> >
> > I'll look into it.
> >
> > Thanks for reporting this.
> >
> > Dave
> >
> >> Please could you tell if there is a fix available for this or a
> >> parameter that can be adjusted when generating the code?
> >>
> >> Thank you and best regards, Andrii
> >>
> 

-- 

Dave Kuhlman
http://www.davekuhlman.org

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to