[dsdl-discuss] Re: Strawman: bringing the framework inside schemas

From: Rick Jelliffe <ricko@topologi.com>
Date: Thu May 30 2002 - 08:00:25 UTC

From: "Martin Bryan" <mtbryan@sgml.u-net.com>
 
> You can''t use integer to validate dates - you have to use specific
> datatypes, with specific ranges. The key factor is that the ranges interact,
> so if the month is 2 then you can't have 30 or 31 in your day field, and you
> can only have 29 if the year is divisible by 4 but not by 100, etc.
>
> You need to clearly indicate which part of DSDL each of the unqualified
> elements belongs to. (I presume the ie: entries in the Intro equate to the
> if: ones later in the spec, but am not sure where many of the others come
> from.) Where do fragmentRules, applyTo and produce all sit in the DSDL
> scheme of things?

Here is how I would imagine dates should work, under my druthers. Note that
we can validate exactly your constraints for dates!

Original:

  <USdate>12/31/02</USdate>

Tokenized and typed:

  <dsdl:bag type="gDate">
       <dsdl:number unit="month">12</dsdl:number>
       <dsdl:number unit="day">31</dsdl:number>
       <dsdl:number unit="year">02</dsdl:number>
  </dsdl:bag>

Schematron schema:

   <rule context="*[@type='USdate']">
        <assert test="number(dsdl:number[@unit='month'])=2 and
                   number(dsdl:number[@unit='day']) &lt; 30" >
           If the month is 2 then you can't have 30 or 31 in your day field
        </assert>
        <report test="(number(dsdl:number[@unit='day'])=29) and
                 (!(number(dsdl:number[@unit='year'])) = 0) and
                 (number(dsdl:number[@unit='year'])) mod 4 = 0 ">
            You can only have 29 if the year is divisible by 4 but not by 100.
        </report>
    </rule>

Cheers
Rick Jelliffe

--
DSDL members discussion list
To unsubscribe, please send a message with the
command  "unsubscribe" to dsdl-discuss-request@dsdl.org
(mailto:dsdl-discuss-request@dsdl.org?Subject=unsubscribe)
Received on Thu May 30 03:48:49 2002

This archive was generated by hypermail 2.1.8 : Fri Dec 03 2004 - 14:00:27 UTC