Forum - XML Standard

 View Only
  • 1.  Dates in XML

    Posted 05-06-2021 02:32 PM
    Kathleen Thoburn

    I see from the XML dictionary that dates have an XML data type assigned of "date". Can you please provide a complete definition of what that means? I don't see anything on the NAACCR XML website that defines this (if there is a resource, please point me there). A simple Google search isn't 100% clear, but the most frequent answer is that form supports CCYY-MM-DD. Are the hyphens literal? if this is no longer a "text" data type, how are incomplete dates handled in the XML standard?

    Fabian Depry

    Hello Kathleen,

    The "date" format is defined in the XML Implementation Guide that is posted on the NAACCR website; here is what those specifications say about that format:

    "A NAACCR-style full or partial date (yyyy, yyyymm or yyyymmdd)."

    And here is the regular expression the specifications define for the type:
    ^(18|19|20)\d\d((0[1-9]|1[012])(0[1-9]|[12]\d|3[01])?)?$

    And so the following are valid dates (no trailing spaces):
    20190615
    201906
    2019

    The format doesn't allow a known day and unknown year/month or a known day/month and an unknown year.

    Many invalid dates (future dates, or dates with a day that is too high for a given month) will be deemed "valid" by this definition; I think the idea was to be able to use a simple regular expression to define what is acceptable and not acceptable and to let edits deal with corner cases.

    Kathleen Thoburn

    Okay, so the "date" data type specified for the NAACCR XML Standard is a special data type defined by NAACCR and not interoperable with other XML date data type standards? It truly represents the same 8 character space that is currently in the NAACCR ASCII Standard?

    Fabian Depry

    That's correct, the "date" type is the same one that is currently used in the fixed-column files (without the trailing spaces). It's not related to those more complex "XML" date types.