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

Overview
Comment:Added xsd as new format (and default) to the text constraint command "number".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: c2b6dd2267ec102f63a4868f93a204c7e2cf959752bdf8c5e52d961a22d3e03d
User & Date: rolf 2019-10-24 14:12:14
Context
2019-11-04
18:08
Added simple recovery, with infrastructure to add more fancy recovery features without too much fall out. Added info expected, which returns the expected (possible) events, even in a validation error report handler. check-in: a16fad774f user: rolf tags: schema
2019-10-24
22:05
Merged from trunk. check-in: c416325b0b user: rolf tags: wip
14:12
Added xsd as new format (and default) to the text constraint command "number". check-in: c2b6dd2267 user: rolf tags: schema
11:13
Further work on the schema command "event" method. check-in: 644a84f1b9 user: rolf tags: schema
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

5015
5016
5017
5018
5019
5020
5021
5022





















5023
5024
5025
5026
5027
5028
5029
....
5039
5040
5041
5042
5043
5044
5045








5046
5047
5048
5049








5050


5051





5052
5053
5054
5055
5056
5057
5058
    checkNrArgs (1,1,"No arguments expected");
    ADD_CONSTRAINT (sdata, sc)
    sc->constraint = nmtokensImpl;
    return TCL_OK;
}

static int
numberImpl (





















    Tcl_Interp *interp,
    void *constraintData,
    char *text
    )
{
    double d;

................................................................................
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[]
    )
{
    SchemaData *sdata = GETASI;
    SchemaConstraint *sc;









    CHECK_TI
    CHECK_TOPLEVEL
    checkNrArgs (1,1,"No arguments expected");








    ADD_CONSTRAINT (sdata, sc)


    sc->constraint = numberImpl;





    return TCL_OK;
}

static int
booleanImplXsd (
    Tcl_Interp *interp,
    void *constraintData,







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>



|
>
>
>
>
>
>
>
>

>
>
|
>
>
>
>
>







5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
....
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
    checkNrArgs (1,1,"No arguments expected");
    ADD_CONSTRAINT (sdata, sc)
    sc->constraint = nmtokensImpl;
    return TCL_OK;
}

static int
numberImplXsd (
    Tcl_Interp *interp,
    void *constraintData,
    char *text
    )
{
    char *c = text;
    if (!*c) return 0;
    if (*c == '-' || *c == '+') c++;
    while (isdigit(*c)) {
        c++;
    }
    if (*c == '.') c++;
    while (isdigit(*c)) {
        c++;
    }
    if (*c) return 0;
    return 1;
}

static int
numberImplTcl (
    Tcl_Interp *interp,
    void *constraintData,
    char *text
    )
{
    double d;

................................................................................
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[]
    )
{
    SchemaData *sdata = GETASI;
    SchemaConstraint *sc;
    int type;

    static const char *types[] = {
        "xsd", "tcl", NULL
    };
    enum typeSyms {
        t_xsd, t_tcl
    };

    CHECK_TI
    CHECK_TOPLEVEL
    checkNrArgs (1,2,"?xsd|tcl?");
    if (objc == 1) {
        type = t_xsd;
    } else {
        if (Tcl_GetIndexFromObj (interp, objv[1], types, "type", 0, &type)
            != TCL_OK) {
            return TCL_ERROR;
        }
    }
    ADD_CONSTRAINT (sdata, sc)
    switch ((enum typeSyms) type) {
    case t_xsd:
        sc->constraint = numberImplXsd;
        break;
    case t_tcl:
        sc->constraint = numberImplTcl;
        break;
    }
    return TCL_OK;
}

static int
booleanImplXsd (
    Tcl_Interp *interp,
    void *constraintData,

Changes to tests/schema.test.

3433
3434
3435
3436
3437
3438
3439
3440




























3441
3442
3443
3444
3445
3446
3447
3448
3449
3450

3451
3452



3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
    } {
        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} {




























    tdom::schema s
    s define {
        defelement doc {
            text number
        }
    }
    set result [list]
    foreach xml {
        <doc/>
        <doc></doc>

        <doc>foo</doc>
        <doc>1</doc>



        <doc>12</doc>
        <doc>1234-12-31</doc>
        <doc>-14.23</doc>
        <doc>.777</doc>
        <doc>-1.2e5</doc>
        {<doc> -1.2e5 </doc>}
        {<doc> -1.2e5 e</doc>}
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 1 1 0 1 1 1 1 0}

test schema-14.11 {text: maxLength} {
    tdom::schema s
    s define {
        defelement doc {
            text {
                maxLength 6







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>










>


>
>
>












|







3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
    } {
        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}
        }
    }
    set result [list]
    foreach xml {
        <doc/>
        <doc></doc>
        {<doc> </doc>}
        <doc>foo</doc>
        <doc>1</doc>
        <doc>12</doc>
        <doc>1234-12-31</doc>
        <doc>-14.23</doc>
        <doc>.777</doc>
        <doc>-1.2e5</doc>
        {<doc> -1.2e5 </doc>}
        {<doc> -1.2e5 e</doc>}
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 0 1 1 0 1 1 1 1 0}

test schema-14.10a {text: number xsd} {
    tdom::schema s
    s define {
        defelement doc {
            text number
        }
    }
    set result [list]
    foreach xml {
        <doc/>
        <doc></doc>
        {<doc> </doc>}
        <doc>foo</doc>
        <doc>1</doc>
        {<doc> 1</doc>}
        {<doc>1 </doc>}
        {<doc> 1 </doc>}
        <doc>12</doc>
        <doc>1234-12-31</doc>
        <doc>-14.23</doc>
        <doc>.777</doc>
        <doc>-1.2e5</doc>
        {<doc> -1.2e5 </doc>}
        {<doc> -1.2e5 e</doc>}
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 0 1 0 0 0 1 0 1 1 0 0 0}

test schema-14.11 {text: maxLength} {
    tdom::schema s
    s define {
        defelement doc {
            text {
                maxLength 6