tDOM

Check-in [a5c155ee31]
Login

Check-in [a5c155ee31]

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

Overview
Comment:More work on validation error recovering.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: a5c155ee3148f4c7f585dde58d884584f63a113146b8f16ba4cff4e2dc37d7b0
User & Date: rolf 2019-04-15 23:20:07.759
Context
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
2019-03-30
01:31
More gardening towards reportcmd. check-in: 7319d6926f user: rolf tags: wip
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/schema.c.
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
                Tcl_AppendResult (interp, namespace, ":", NULL);
            }
            Tcl_AppendResult (interp, name, "\"", NULL);
            return TCL_ERROR;
        }
    } else {
        if (!pattern) {
            if (recover (interp, sdata, S("UNKNOWN_DOKUMENT_ELEMENT"))) {
                sdata->skipDeep = 1;
                return TCL_OK;
            }
            SetResult ("Unknown element");
            return TCL_ERROR;
        }
        pushToStack (sdata, pattern);







|







1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
                Tcl_AppendResult (interp, namespace, ":", NULL);
            }
            Tcl_AppendResult (interp, name, "\"", NULL);
            return TCL_ERROR;
        }
    } else {
        if (!pattern) {
            if (recover (interp, sdata, S("UNKNOWN_ROOT_ELEMENT"))) {
                sdata->skipDeep = 1;
                return TCL_OK;
            }
            SetResult ("Unknown element");
            return TCL_ERROR;
        }
        pushToStack (sdata, pattern);
1173
1174
1175
1176
1177
1178
1179
1180


1181
1182
1183
1184
1185

1186
1187
1188
1189
1190
1191
1192
1193

1194
1195

1196
1197
1198
1199
1200
1201
1202
                if (!cp->attrs[i]->namespace
                    || (strcmp (cp->attrs[i]->namespace, namespace) != 0))
                    continue;
            }
            if (strcmp (ln, cp->attrs[i]->name) == 0) {
                found = 1;
                if (cp->attrs[i]->cp) {
                    if (checkText (interp, cp->attrs[i]->cp, (char *) atPtr[1])


                        == 0) {
                        if (nsatt) namespace[j] = '\xFF';
                        SetResult3 ("Attribute value doesn't match for "
                                    "attribute '", atPtr[0], "'");
                        return TCL_ERROR;

                    }
                }
                if (cp->attrs[i]->required) reqAttr++;
                break;
            }
        }
        if (nsatt) namespace[j] = '\xFF';
        if (!found) {

            SetResult3 ("Unknown attribute \"", atPtr[0], "\"");
            return TCL_ERROR;

        }
    }
    if (reqAttr != cp->numReqAttr) {
        /* Lookup the missing attribute(s) */
        SetResult ("Missing mandatory attribute(s):");
        for (i = 0; i < cp->numAttr; i++) {
            if (!cp->attrs[i]->required) continue;







|
>
>
|
|
|
|
|
>








>
|
|
>







1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
                if (!cp->attrs[i]->namespace
                    || (strcmp (cp->attrs[i]->namespace, namespace) != 0))
                    continue;
            }
            if (strcmp (ln, cp->attrs[i]->name) == 0) {
                found = 1;
                if (cp->attrs[i]->cp) {
                    if (!checkText (interp, cp->attrs[i]->cp,
                                    (char *) atPtr[1])) {
                        if (!recover (interp, sdata,
                                      S("WRONG_ATTRIBUTE_VALUE"))) {
                            if (nsatt) namespace[j] = '\xFF';
                            SetResult3 ("Attribute value doesn't match for "
                                        "attribute '", atPtr[0], "'");
                            return TCL_ERROR;
                        }
                    }
                }
                if (cp->attrs[i]->required) reqAttr++;
                break;
            }
        }
        if (nsatt) namespace[j] = '\xFF';
        if (!found) {
            if (!recover (interp, sdata, S("UNKNOWN_ATTRIBUTE"))) {
                SetResult3 ("Unknown attribute \"", atPtr[0], "\"");
                return TCL_ERROR;
            }
        }
    }
    if (reqAttr != cp->numReqAttr) {
        /* Lookup the missing attribute(s) */
        SetResult ("Missing mandatory attribute(s):");
        for (i = 0; i < cp->numAttr; i++) {
            if (!cp->attrs[i]->required) continue;
1222
1223
1224
1225
1226
1227
1228

1229
1230
1231
1232
1233

1234
1235
1236

1237

1238
1239
1240
1241
1242
1243
1244
                }
                if (strcmp (atPtr[0], cp->attrs[i]->name) == 0) {
                    found = 1;
                    break;
                }
            }
            if (!found) {

                if (cp->attrs[i]->namespace) {
                    Tcl_AppendResult (interp, " ", cp->attrs[i]->namespace,
                                      ":", cp->attrs[i]->name, NULL);
                } else {
                    Tcl_AppendResult (interp, " ", cp->attrs[i]->name, NULL);

                }
            }
        }

        return TCL_ERROR;

    }
    return TCL_OK;
}

int probeDomAttributes (
    Tcl_Interp *interp,
    SchemaData *sdata,







>
|
|
|
|
|
>



>
|
>







1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
                }
                if (strcmp (atPtr[0], cp->attrs[i]->name) == 0) {
                    found = 1;
                    break;
                }
            }
            if (!found) {
                if (!recover (interp, sdata, S("MISSING_ATTRIBUTE"))) {
                    if (cp->attrs[i]->namespace) {
                        Tcl_AppendResult (interp, " ", cp->attrs[i]->namespace,
                                          ":", cp->attrs[i]->name, NULL);
                    } else {
                        Tcl_AppendResult (interp, " ", cp->attrs[i]->name, NULL);
                    }
                }
            }
        }
        if (!sdata->reportCmd) {
            return TCL_ERROR;
        }
    }
    return TCL_OK;
}

int probeDomAttributes (
    Tcl_Interp *interp,
    SchemaData *sdata,
1275
1276
1277
1278
1279
1280
1281
1282


1283
1284
1285
1286

1287
1288
1289
1290
1291
1292
1293
1294

1295
1296
1297
1298
1299
1300
1301
1302
1303

1304
1305
1306
1307
1308
1309
1310
                if (!cp->attrs[i]->namespace) continue;
                if (strcmp (ns, cp->attrs[i]->namespace) != 0) continue;
            } else {
                if (cp->attrs[i]->namespace) continue;
            }
            if (strcmp (ln, cp->attrs[i]->name) == 0) {
                if (cp->attrs[i]->cp) {
                    if (checkText (interp, cp->attrs[i]->cp, (char *) atPtr->nodeValue)


                        == 0) {
                        SetResult3 ("Attribute value doesn't match for "
                                    "attribute '", ln, "'");
                        return TCL_ERROR;

                    }
                }
                found = 1;
                if (cp->attrs[i]->required) reqAttr++;
                break;
            }
        }
        if (!found) {

            if (ns) {
                SetResult ("Unknown attribute \"");
                Tcl_AppendResult (interp, ns, ":", atPtr->nodeName,
                                  "\"");
            } else {
                SetResult3 ("Unknown attribute \"", atPtr->nodeName, "\"");
            }
            sdata->validationState = VALIDATION_ERROR;
            return TCL_ERROR;

        }
    nextAttr:
        atPtr = atPtr->nextSibling;
    }
    if (reqAttr != cp->numReqAttr) {
        /* Lookup the missing attribute(s) */
        SetResult ("Missing mandatory attribute(s):");







|
>
>
|
|
|
|
>








>
|
|
|
|
|
|
|
|
|
>







1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
                if (!cp->attrs[i]->namespace) continue;
                if (strcmp (ns, cp->attrs[i]->namespace) != 0) continue;
            } else {
                if (cp->attrs[i]->namespace) continue;
            }
            if (strcmp (ln, cp->attrs[i]->name) == 0) {
                if (cp->attrs[i]->cp) {
                    if (!checkText (interp, cp->attrs[i]->cp,
                                    (char *) atPtr->nodeValue)) {
                        if (!recover (interp, sdata,
                                      S("WRONG_ATTRIBUTE_VALUE"))) {
                            SetResult3 ("Attribute value doesn't match for "
                                        "attribute '", ln, "'");
                            return TCL_ERROR;
                        }
                    }
                }
                found = 1;
                if (cp->attrs[i]->required) reqAttr++;
                break;
            }
        }
        if (!found) {
            if (!recover (interp, sdata, S("UNKNOWN_ATTRIBUTE"))) {
                if (ns) {
                    SetResult ("Unknown attribute \"");
                    Tcl_AppendResult (interp, ns, ":", atPtr->nodeName,
                                      "\"");
                } else {
                    SetResult3 ("Unknown attribute \"", atPtr->nodeName, "\"");
                }
                sdata->validationState = VALIDATION_ERROR;
                return TCL_ERROR;
            }
        }
    nextAttr:
        atPtr = atPtr->nextSibling;
    }
    if (reqAttr != cp->numReqAttr) {
        /* Lookup the missing attribute(s) */
        SetResult ("Missing mandatory attribute(s):");
1335
1336
1337
1338
1339
1340
1341

1342
1343
1344
1345
1346


1347
1348
1349

1350
1351

1352
1353
1354
1355
1356
1357
1358
                    found = 1;
                    break;
                }
            nextAttr2:
                atPtr = atPtr->nextSibling;
            }
            if (!found) {

                if (cp->attrs[i]->namespace) {
                    Tcl_AppendResult (interp, " ", cp->attrs[i]->namespace,
                                      ":", cp->attrs[i]->name, NULL);
                } else {
                    Tcl_AppendResult (interp, " ", cp->attrs[i]->name, NULL);


                }
            }
        }

        sdata->validationState = VALIDATION_ERROR;
        return TCL_ERROR;

    }
    return TCL_OK;
}

static int checkElementEnd (
    Tcl_Interp *interp,
    SchemaData *sdata







>
|
|
|
|
|
>
>



>
|
|
>







1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
                    found = 1;
                    break;
                }
            nextAttr2:
                atPtr = atPtr->nextSibling;
            }
            if (!found) {
                if (!recover (interp, sdata, S("MISSING_ATTRIBUTE"))) {
                    if (cp->attrs[i]->namespace) {
                        Tcl_AppendResult (interp, " ", cp->attrs[i]->namespace,
                                          ":", cp->attrs[i]->name, NULL);
                    } else {
                        Tcl_AppendResult (interp, " ", cp->attrs[i]->name,
                                          NULL);
                    }
                }
            }
        }
        if (!sdata->reportCmd) {
            sdata->validationState = VALIDATION_ERROR;
            return TCL_ERROR;
        }
    }
    return TCL_OK;
}

static int checkElementEnd (
    Tcl_Interp *interp,
    SchemaData *sdata
1384
1385
1386
1387
1388
1389
1390



1391
1392
1393
1394
1395
1396
1397
                ac++; continue;
            }
            
            switch (cp->content[ac]->type) {
            case SCHEMA_CTYPE_TEXT:
                if (cp->content[ac]->nc) {
                    if (!checkText (interp, cp->content[ac], "")) {



                        return 0;
                    }
                }
                break;

            case SCHEMA_CTYPE_CHOICE:
                mayMiss = 0;







>
>
>







1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
                ac++; continue;
            }
            
            switch (cp->content[ac]->type) {
            case SCHEMA_CTYPE_TEXT:
                if (cp->content[ac]->nc) {
                    if (!checkText (interp, cp->content[ac], "")) {
                        if (recover (interp, sdata, S("MISSING_TEXT"))) {
                            break;
                        }
                        return 0;
                    }
                }
                break;

            case SCHEMA_CTYPE_CHOICE:
                mayMiss = 0;
1429
1430
1431
1432
1433
1434
1435

1436
1437


1438
1439
1440
1441
1442
1443
1444
                    case SCHEMA_CTYPE_VIRTUAL:
                        Tcl_Panic ("Virtual constrain in MIXED or CHOICE");
                        
                    }
                    if (mayMiss) break;
                }
                if (mayMiss) break;

                return 0;



            case SCHEMA_CTYPE_VIRTUAL:
                if (evalVirtual (interp, sdata, cp->content[ac])) break;
                else return 0;
                
            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
                pushToStack (sdata, cp->content[ac]);







>
|
|
>
>







1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
                    case SCHEMA_CTYPE_VIRTUAL:
                        Tcl_Panic ("Virtual constrain in MIXED or CHOICE");
                        
                    }
                    if (mayMiss) break;
                }
                if (mayMiss) break;
                if (!recover (interp, sdata, S("MISSING_ONE_OF_CHOICE"))) {
                    return 0;
                }
                break;
                
            case SCHEMA_CTYPE_VIRTUAL:
                if (evalVirtual (interp, sdata, cp->content[ac])) break;
                else return 0;
                
            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
                pushToStack (sdata, cp->content[ac]);
Changes to tests/schema.test.
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
    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
        }







|







3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
    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
        }