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

Overview
Comment:Working on more control over recovering for certain events.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: a07b509a442f709b40c43c0d499783cb8a5bb1755176eaa4801abbeef9c759a1
User & Date: rolf 2020-03-20 02:31:40
Context
2020-03-20
19:27
Save work. check-in: 1c292a129a user: rolf tags: wip
02:31
Working on more control over recovering for certain events. check-in: a07b509a44 user: rolf tags: wip
2020-03-19
02:21
Integrated so far done work: bug fixes in recoving, more work on sanitizing recovering, code gardening. check-in: 33ac16a9c2 user: rolf tags: schema
Changes

Changes to generic/schema.c.

171
172
173
174
175
176
177

178
179
180
181
182
183
184
....
1146
1147
1148
1149
1150
1151
1152










1153
1154
1155
1156
1157
1158
1159
....
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421



1422

1423
1424
1425
1426
1427
1428
1429
....
1512
1513
1514
1515
1516
1517
1518

1519


1520
1521
1522
1523
1524
1525
1526
/*----------------------------------------------------------------------------
|   Recover related flage
|
\---------------------------------------------------------------------------*/

#define RECOVER_FLAG_REWIND 1
#define RECOVER_FLAG_DONT_REPORT 2


/*----------------------------------------------------------------------------
|   domKeyConstraint related flage
|
\---------------------------------------------------------------------------*/

#define DKC_FLAG_IGNORE_EMPTY_FIELD_SET 1
................................................................................
    Tcl_DecrRefCount (cmdPtr);
    if (rc != TCL_OK) {
        sdata->evalError = 1;
        return 0;
    }
    switch (errorType) {
    case MISSING_ELEMENT_MATCH_START:










    case UNEXPECTED_ELEMENT:
        finalizeElement (sdata, ac+1);
        sdata->skipDeep = 2;
        break;
    case UNEXPECTED_TEXT:
        sdata->recoverFlags |= RECOVER_FLAG_REWIND;
        break;
................................................................................
                ac++;
                hm = 0;
                continue;
            }
            if (!mayskip && mustMatch (cp->quants[ac], hm)) {
                if (recover (interp, sdata, MISSING_ELEMENT_MATCH_START, name,
                             namespace, NULL, ac)) {
                    /* Skip the just opened element tag and the following
                     * content of the current. */
                    return 1;
                }



                return 0;

            }
            ac++;
            hm = 0;
        }
        if (isName) {
            if (recover (interp, sdata, UNEXPECTED_ELEMENT, name, namespace,
                         NULL, 0)) {
................................................................................
                break;

            }
        }
        if (mayskip) break;
        if (recover (interp, sdata, MISSING_ELEMENT_MATCH_START, name,
                     namespace, NULL, cp->nc)) {

            return 1;


        }
        return 0;
    }
    return -1;
}

static void *







>







 







>
>
>
>
>
>
>
>
>
>







 







|
<
|
|
>
>
>
|
>







 







>
|
>
>







171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
....
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
....
1422
1423
1424
1425
1426
1427
1428
1429

1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
....
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
/*----------------------------------------------------------------------------
|   Recover related flage
|
\---------------------------------------------------------------------------*/

#define RECOVER_FLAG_REWIND 1
#define RECOVER_FLAG_DONT_REPORT 2
#define RECOVER_FLAG_IGNORE 4

/*----------------------------------------------------------------------------
|   domKeyConstraint related flage
|
\---------------------------------------------------------------------------*/

#define DKC_FLAG_IGNORE_EMPTY_FIELD_SET 1
................................................................................
    Tcl_DecrRefCount (cmdPtr);
    if (rc != TCL_OK) {
        sdata->evalError = 1;
        return 0;
    }
    switch (errorType) {
    case MISSING_ELEMENT_MATCH_START:
        if (strcmp (Tcl_GetStringResult (interp), "ignore") == 0) {
            /* Rewind stack to last match and ignore the just opened
             * Element. */
            sdata->recoverFlags |= RECOVER_FLAG_IGNORE;
            return 1;
        } else {
            finalizeElement (sdata, ac+1);
            sdata->skipDeep = 2;
        }
        break;
    case UNEXPECTED_ELEMENT:
        finalizeElement (sdata, ac+1);
        sdata->skipDeep = 2;
        break;
    case UNEXPECTED_TEXT:
        sdata->recoverFlags |= RECOVER_FLAG_REWIND;
        break;
................................................................................
                ac++;
                hm = 0;
                continue;
            }
            if (!mayskip && mustMatch (cp->quants[ac], hm)) {
                if (recover (interp, sdata, MISSING_ELEMENT_MATCH_START, name,
                             namespace, NULL, ac)) {
                    if (!(sdata->recoverFlags & RECOVER_FLAG_IGNORE)) {

                        return 1;
                    }
                    /* This fail throu to skip to the next
                     * candidate. */
                } else {
                    return 0;
                }
            }
            ac++;
            hm = 0;
        }
        if (isName) {
            if (recover (interp, sdata, UNEXPECTED_ELEMENT, name, namespace,
                         NULL, 0)) {
................................................................................
                break;

            }
        }
        if (mayskip) break;
        if (recover (interp, sdata, MISSING_ELEMENT_MATCH_START, name,
                     namespace, NULL, cp->nc)) {
            if (!(sdata->recoverFlags & RECOVER_FLAG_IGNORE)) {
                return 1;
            }
            break;
        }
        return 0;
    }
    return -1;
}

static void *

Changes to tests/schema.test.

6708
6709
6710
6711
6712
6713
6714

6715
6716
6717
6718
6719
6720
6721
....
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
....
7265
7266
7267
7268
7269
7270
7271



















































7272
7273
7274
7275
7276
7277
7278
    set result
} {{<any> {}} {<any> http://foo.bar} {<elementend> {}} b}

proc schema-17.13 {scmd args} {
    global fromReportCmd
    set fromReportCmd [lsort [$scmd info expected]]
}

test schema-17.13 {info expected} {
    set defs {
        {
            element a
            element b ?
        }
        {
................................................................................
        <doc><a/><unknown/></doc>
    }
    set result [list]
    set defnr 0
    foreach def $defs {
        tdom::schema s
        s defelement doc $def
        s reportcmd schema-17.13
        set xmlnr 0
        foreach xml $xmlinput {
            set fromReportCmd ""
            lappend result $defnr/$xmlnr: [s validate $xml errMsg]
            lappend result {*}$fromReportCmd
            incr xmlnr
        }
................................................................................
    }
    s reportcmd schema-17.21a
    set result ""
    lappend result [s validate {<doc><a/><unexpected/></doc>}]
    s delete
    set result
} {b 1}




















































proc schema-18 {args} {
    lappend ::result {*}$args
}
test schema-18.1 {reportcmd} {
    tdom::schema s
    s define {







>







 







|







 







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







6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
....
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
....
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
    set result
} {{<any> {}} {<any> http://foo.bar} {<elementend> {}} b}

proc schema-17.13 {scmd args} {
    global fromReportCmd
    set fromReportCmd [lsort [$scmd info expected]]
}

test schema-17.13 {info expected} {
    set defs {
        {
            element a
            element b ?
        }
        {
................................................................................
        <doc><a/><unknown/></doc>
    }
    set result [list]
    set defnr 0
    foreach def $defs {
        tdom::schema s
        s defelement doc $def
        s reportcmd schema-17.13a
        set xmlnr 0
        foreach xml $xmlinput {
            set fromReportCmd ""
            lappend result $defnr/$xmlnr: [s validate $xml errMsg]
            lappend result {*}$fromReportCmd
            incr xmlnr
        }
................................................................................
    }
    s reportcmd schema-17.21a
    set result ""
    lappend result [s validate {<doc><a/><unexpected/></doc>}]
    s delete
    set result
} {b 1}

proc schema-17.22 {scmd errorInfo} {
    global fromReportCmd
    if {[$scmd info vaction] eq "MATCH_ELEMENT_START"} {
        lappend fromReportCmd "[lsort [$scmd info expected]] [$scmd info vaction name]"
        if {$errorInfo eq "MISSING_ELEMENT"} {
            return ignore
        }
    } else {
        lappend fromReportCmd "END_EVENT [$scmd info expected]"
    }
}
# <doc/>
# <doc><a/></doc>
# <doc><b/></doc>
# <doc><c/></doc>
# <doc><a/><b/></doc>
# <doc><a/><c/></doc>
# <doc><b/><c/></doc>
# <doc><unknown/></doc>
# <doc><a/><unknown/></doc>
test schema-17.22 {info expected} {
    set defs {
        {
            element a
            element b
            element c
        }
    }
    set xmlinput {
        <doc><b/></doc>
        <doc><c/></doc>
    }
    set result [list]
    set defnr 0
    foreach def $defs {
        tdom::schema s
        s defelement doc $def
        s reportcmd schema-17.22
        set xmlnr 0
        foreach xml $xmlinput {
            set fromReportCmd ""
            lappend result $defnr/$xmlnr: [s validate $xml errMsg]
            lappend result {*}$fromReportCmd
            incr xmlnr
        }
        s delete
        incr defnr
    }
    set result
} {0/0: 1 {a b} {END_EVENT c}}

proc schema-18 {args} {
    lappend ::result {*}$args
}
test schema-18.1 {reportcmd} {
    tdom::schema s
    s define {