Topic
  • 2 replies
  • Latest Post - ‏2012-01-13T01:17:25Z by rkolla
rkolla
rkolla
3 Posts

Pinned topic What is the valid vaue for date field with restriction CCYYMMDD?

‏2011-12-31T02:07:10Z |
Hello All, Greetings!

I have create a date field in one of the schema definitions as below:
<xs:element name="myDate" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:date">
<xs:pattern value="CCYYMMDD"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
When am passing a value <myDate>20111231</myDate>, I get an error that the value for myDate is invalid.
Could you please make me understand why is it so?

Thank you in advance.

ram
Updated on 2012-01-13T01:17:25Z at 2012-01-13T01:17:25Z by rkolla
  • SystemAdmin
    SystemAdmin
    1391 Posts

    Re: What is the valid vaue for date field with restriction CCYYMMDD?

    ‏2012-01-02T16:20:17Z  
    As far as the pattern itself is concerned, "CCYYMMDD" would be taken literally. So, that format itself would probably be ruled out. But if we take what you actually mean (that can be understood quite clearly), say, something like "\d}\d{2{4}\d{2}" or equivalently "\d{8}", that won't do. The basic reason is that the xs:date per w3c recommendation supports only the ISO8601 extended format for date: the basic format is not supported. From the point of view of schema itself, it creates a new type which value space does not overlap with the value space of xs:date. Lexical-wise, any pattern that makes the separator "-" between CCYY, MM, and DD will bound to fail. Both deductions come back to the same basic reason: namely, ISO8601 basic format is not at all supported, at least as of to-date.

    One possible way out is to let go the base="xs:date". Instead, use base="xs:string" and then restrict it to something like "\d{8}" (or its refinement). In that case, the burden of recognizing CCYY, MM and DD is on the application itself parsing the data and validate the values of each component... representing a date. (That validation part depends on how refine the pattern actually is using: the more refine, the less reliance on the application's validation logic.)
  • rkolla
    rkolla
    3 Posts

    Re: What is the valid vaue for date field with restriction CCYYMMDD?

    ‏2012-01-13T01:17:25Z  
    As far as the pattern itself is concerned, "CCYYMMDD" would be taken literally. So, that format itself would probably be ruled out. But if we take what you actually mean (that can be understood quite clearly), say, something like "\d}\d{2{4}\d{2}" or equivalently "\d{8}", that won't do. The basic reason is that the xs:date per w3c recommendation supports only the ISO8601 extended format for date: the basic format is not supported. From the point of view of schema itself, it creates a new type which value space does not overlap with the value space of xs:date. Lexical-wise, any pattern that makes the separator "-" between CCYY, MM, and DD will bound to fail. Both deductions come back to the same basic reason: namely, ISO8601 basic format is not at all supported, at least as of to-date.

    One possible way out is to let go the base="xs:date". Instead, use base="xs:string" and then restrict it to something like "\d{8}" (or its refinement). In that case, the burden of recognizing CCYY, MM and DD is on the application itself parsing the data and validate the values of each component... representing a date. (That validation part depends on how refine the pattern actually is using: the more refine, the less reliance on the application's validation logic.)
    Thank you for the reply. I understand it now :)