tDOM

Check-in [e1eaa5909b]
Login

Check-in [e1eaa5909b]

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

Overview
Comment:Still work on validation error recovering.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: e1eaa5909b9053ad3fa91462662a21454f6353d5267a4cf7bc5d890b7f020ab4
User & Date: rolf 2019-04-16 23:28:04.292
Context
2019-04-19
15:57
Still work on validation error recovering. Closed-Leaf check-in: a00292f6a2 user: rolf tags: wip
2019-04-16
23:28
Still work on validation error recovering. check-in: e1eaa5909b user: rolf tags: wip
2019-04-15
23:20
More work on validation error recovering. check-in: a5c155ee31 user: rolf tags: wip
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/schema.c.
1
2
3
4
5
6
7
8
9
/*----------------------------------------------------------------------------
|   Copyright (c) 2018  Rolf Ade ([email protected])
|-----------------------------------------------------------------------------
|
|
|   The contents of this file are subject to the Mozilla Public License
|   Version 2.0 (the "License"); you may not use this file except in
|   compliance with the License. You may obtain a copy of the License at
|   http://www.mozilla.org/MPL/

|







1
2
3
4
5
6
7
8
9
/*----------------------------------------------------------------------------
|   Copyright (c) 2018, 2019  Rolf Ade ([email protected])
|-----------------------------------------------------------------------------
|
|
|   The contents of this file are subject to the Mozilla Public License
|   Version 2.0 (the "License"); you may not use this file except in
|   compliance with the License. You may obtain a copy of the License at
|   http://www.mozilla.org/MPL/
803
804
805
806
807
808
809

810
811
812
813
814
815
816
            candidate = cp->content[ac];
            mayskip = 0;
            switch (candidate->type) {
            case SCHEMA_CTYPE_TEXT:
                if (candidate->nc) {
                    if (!checkText (interp, candidate, "")) {
                        if (recover (interp, sdata, S("MISSING_TEXT"))) {

                            break;
                        }                        
                        return 0;
                    }
                }
                break;








>







803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
            candidate = cp->content[ac];
            mayskip = 0;
            switch (candidate->type) {
            case SCHEMA_CTYPE_TEXT:
                if (candidate->nc) {
                    if (!checkText (interp, candidate, "")) {
                        if (recover (interp, sdata, S("MISSING_TEXT"))) {
                            mayskip = 1;
                            break;
                        }                        
                        return 0;
                    }
                }
                break;

1470
1471
1472
1473
1474
1475
1476



1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494



1495
1496
1497
1498
1499
1500
1501
                rc = checkElementEnd (interp, sdata);
                popStack (sdata);
                if (rc) break;
                return 0;
                
            case SCHEMA_CTYPE_ANY:
            case SCHEMA_CTYPE_NAME:



                return 0;
            }
            ac++;
        }
        if (isName) return 1;
        return -1;

    case SCHEMA_CTYPE_VIRTUAL:
    case SCHEMA_CTYPE_CHOICE:
    case SCHEMA_CTYPE_TEXT:
    case SCHEMA_CTYPE_ANY:
        /* Never pushed onto stack */
        Tcl_Panic ("Invalid CTYPE onto the validation stack!");
        return 0;

    case SCHEMA_CTYPE_INTERLEAVE:
        for (i = 0; i < cp->nc; i++) {
            if (mustMatch (cp->quants[i], se->interleaveState[i])) {



                return 0;
            }
        }
        return -1;
    }
    return 0;
}







>
>
>


















>
>
>







1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
                rc = checkElementEnd (interp, sdata);
                popStack (sdata);
                if (rc) break;
                return 0;
                
            case SCHEMA_CTYPE_ANY:
            case SCHEMA_CTYPE_NAME:
                if (recover (interp, sdata, S("MISSING_ELEMENT"))) {
                    break;
                }
                return 0;
            }
            ac++;
        }
        if (isName) return 1;
        return -1;

    case SCHEMA_CTYPE_VIRTUAL:
    case SCHEMA_CTYPE_CHOICE:
    case SCHEMA_CTYPE_TEXT:
    case SCHEMA_CTYPE_ANY:
        /* Never pushed onto stack */
        Tcl_Panic ("Invalid CTYPE onto the validation stack!");
        return 0;

    case SCHEMA_CTYPE_INTERLEAVE:
        for (i = 0; i < cp->nc; i++) {
            if (mustMatch (cp->quants[i], se->interleaveState[i])) {
                if (recover (interp, sdata, S("MISSING_ONE_OF_INTERLEAVE"))) {
                    break;
                }
                return 0;
            }
        }
        return -1;
    }
    return 0;
}
Changes to tests/schema.test.
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793

















3794
3795
3796
3797
3798
3799
3800
3801
    s delete
    set result
} {a b}

proc schema-18 {args} {
    lappend ::result {*}$args
}
test schema-18.1 {reportcmd} knownBug {
    tdom::schema s
    s define {
        defelement doc {
            element e
            text {minLength 1}
            element e
        }
    }
    s reportcmd schema-18
    set result ""
    set rc [s validate {<doc><e/></doc>} errMsg]
    puts $errMsg
    lappend result $rc
    s delete
    set result

















} {MISSING_TEXT s 1}

test schema-18.2 {reportcmd} {
    tdom::schema s
    s define {
        defelement doc {
            element a
            element b







|















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







3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
    s delete
    set result
} {a b}

proc schema-18 {args} {
    lappend ::result {*}$args
}
test schema-18.1 {reportcmd} {
    tdom::schema s
    s define {
        defelement doc {
            element e
            text {minLength 1}
            element e
        }
    }
    s reportcmd schema-18
    set result ""
    set rc [s validate {<doc><e/></doc>} errMsg]
    puts $errMsg
    lappend result $rc
    s delete
    set result
} {s MISSING_TEXT s MISSING_ELEMENT 1}

test schema-18.1a {reportcmd} {
    tdom::schema s
    s define {
        defelement doc {
            element e
            text {minLength 1}
            element e
        }
    }
    s reportcmd schema-18
    set result ""
    set rc [s validate {<doc><e/><e/></doc>}]
    lappend result $rc
    s delete
    set result
} {s MISSING_TEXT 1}

test schema-18.2 {reportcmd} {
    tdom::schema s
    s define {
        defelement doc {
            element a
            element b
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
        <bar><a><b/></a></bar>
    } {
        set rc [s validate $xml]
        lappend result $rc
    }
    s delete
    set result
} {s UNKNOWN_DOKUMENT_ELEMENT 1 s UNKNOWN_DOKUMENT_ELEMENT 1 s UNKNOWN_DOKUMENT_ELEMENT 1 s UNKNOWN_DOKUMENT_ELEMENT 1}

proc validatedSAX {g xml {keepEmpties 1}} {
    set args [list -validateCmd $g]
    if {!$keepEmpties} {
        lappend args -ignorewhitespace 1
    }
    xml::parser p {*}$args







|







3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
        <bar><a><b/></a></bar>
    } {
        set rc [s validate $xml]
        lappend result $rc
    }
    s delete
    set result
} {s UNKNOWN_ROOT_ELEMENT 1 s UNKNOWN_ROOT_ELEMENT 1 s UNKNOWN_ROOT_ELEMENT 1 s UNKNOWN_ROOT_ELEMENT 1}

proc validatedSAX {g xml {keepEmpties 1}} {
    set args [list -validateCmd $g]
    if {!$keepEmpties} {
        lappend args -ignorewhitespace 1
    }
    xml::parser p {*}$args