Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added optional time zone check to text constraint isodate, making it fully xsd:date compliant.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 7cf1968eb301bbbecec20bf6ccce1329524ac7c082e7b537deaa78de6030ba9a
User & Date: rolf 2019-11-14 14:09:22
Context
2019-11-15
09:30
Prevent call of the recovery report command in case of probed optional not matching pattern. Added recovery in a so far not handled case. check-in: 1ceabd63a5 user: rolf tags: schema
2019-11-14
14:09
Added optional time zone check to text constraint isodate, making it fully xsd:date compliant. check-in: 7cf1968eb3 user: rolf tags: schema
12:58
Added more documentation. check-in: 78462d5d87 user: rolf tags: schema
Changes

Changes to generic/schema.c.

5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
....
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
....
5631
5632
5633
5634
5635
5636
5637
































5638
5639
5640
5641
5642
5643
5644
static int
isodateImpl (
    Tcl_Interp *interp,
    void *constraintData,
    char *text
    )
{
    int i, y, m, d, seenNonzero = 0;

    if (*text == '-') {
        /* A bce date */
        text++;
    }
    for (i = 0; i < 4; i++) {
        if (*text < '0' || *text > '9') return 0;
................................................................................
    m = atoi(text-2);
    if (m < 1 || m > 12) return 0;
    text++;
    for (i = 0; i < 2; i++) {
        if (*text < '0' || *text > '9') return 0;
        text++;
    }
    if (*text != '\0') return 0;
    d = atoi(text-2);
    if (d < 1) return 0;
    switch (m) {
    case 1:
    case 3:
    case 5:
    case 7:
................................................................................
    case 2:
        if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
            if (d > 29) return 0;
        } else {
            if (d > 28) return 0;
        }
        break;
































    }
    return 1;
}

static int
isodateTCObjCmd (
    ClientData clientData,







|







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
....
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
....
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
static int
isodateImpl (
    Tcl_Interp *interp,
    void *constraintData,
    char *text
    )
{
    int i, y, m, d, h, min, seenNonzero = 0, timezone = 0;

    if (*text == '-') {
        /* A bce date */
        text++;
    }
    for (i = 0; i < 4; i++) {
        if (*text < '0' || *text > '9') return 0;
................................................................................
    m = atoi(text-2);
    if (m < 1 || m > 12) return 0;
    text++;
    for (i = 0; i < 2; i++) {
        if (*text < '0' || *text > '9') return 0;
        text++;
    }
    if (*text != '\0') timezone = 1;
    d = atoi(text-2);
    if (d < 1) return 0;
    switch (m) {
    case 1:
    case 3:
    case 5:
    case 7:
................................................................................
    case 2:
        if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)) {
            if (d > 29) return 0;
        } else {
            if (d > 28) return 0;
        }
        break;
    }
    if (!timezone) return 1;
    switch (*text) {
    case 'Z':
        text++;
        if (*text != '\0') return 0;
        break;
    case '+':
    case '-':
        text++;
        for (i = 0; i < 2; i++) {
            if (*text < '0' || *text > '9') return 0;
            text++;
        }
        if (*text != ':') return 0;
        h = atoi(text-2);
        if (h > 14) return 0;
        text++;
        for (i = 0; i < 2; i++) {
            if (*text < '0' || *text > '9') return 0;
            text++;
        }
        if (*text != '\0') return 0;
        min = atoi(text-2);
        if (h < 14) {
            if (min > 59) return 0;
        } else {
            if (min != 0) return 0;
        }
        break;
    default:
        return 0;
    }
    return 1;
}

static int
isodateTCObjCmd (
    ClientData clientData,

Changes to tests/schema.test.

3576
3577
3578
3579
3580
3581
3582

















3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
        <doc>1234-08-222</doc>
        {<doc> 1234-08-22</doc>}
        {<doc>1234-08-22 </doc>}
        <doc>11234-08-22</doc>
        <doc>0000-02-01</doc>
        <doc>10000-08-22</doc>
        <doc>10000-02-29</doc>

















    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 0 0 1 0 1 1}

test schema-14.10 {text: number tcl} {
    tdom::schema s
    s define {
        defelement doc {
            text {number tcl}
        }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





|







3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
        <doc>1234-08-222</doc>
        {<doc> 1234-08-22</doc>}
        {<doc>1234-08-22 </doc>}
        <doc>11234-08-22</doc>
        <doc>0000-02-01</doc>
        <doc>10000-08-22</doc>
        <doc>10000-02-29</doc>
        <doc>10000-02-29Z</doc>
        <doc>2012-03-07Z</doc>
        {<doc>2012-03-07Z </doc>}
        <doc>2012-03-07a</doc>
        <doc>2012-03-07+</doc>
        <doc>2012-03-07+00:00</doc>
        <doc>2012-03-07-00:00</doc>
        <doc>2012-03-07+02:00</doc>
        <doc>2012-03-07+02:70</doc>
        <doc>2012-03-07+12:30</doc>
        <doc>2012-03-07+14:30</doc>
        <doc>2012-03-07+14:00</doc>
        <doc>2012-03-07-14:00</doc>
        <doc>2012-03-07-14:01</doc>
        <doc>2012-03-07-2:30</doc>
        <doc>2012-03-07-02:30Z</doc>
        {<doc>2012-03-07-02:30 </doc>}
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 0 0 1 0 1 1 1 1 0 0 0 1 1 1 0 1 0 1 1 0 0 0 0}

test schema-14.10 {text: number tcl} {
    tdom::schema s
    s define {
        defelement doc {
            text {number tcl}
        }