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

Overview
Comment:Better handling of validation command using SAX parser in partial parsing mode (-final 0).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 266d76531fee0b030bb34e6dfb67ec0dd0c5303323fb61a38a1ad8815cb9e836
User & Date: rolf 2020-02-11 16:28:22
Context
2020-02-11
20:02
Enforce that only an element defined by defelement can be document element of the xml to validate. Added documentation for the content definition command "elementtype". check-in: f84ee35226 user: rolf tags: schema
16:28
Better handling of validation command using SAX parser in partial parsing mode (-final 0). check-in: 266d76531f user: rolf tags: schema
2020-02-10
22:38
Added a few tests. check-in: d1c94a212f user: rolf tags: schema
Changes

Changes to generic/tclexpat.c.

843
844
845
846
847
848
849







850
851
852
853
854
855
856
        if (expat->final || result != TCL_OK) {
#ifndef TDOM_NO_SCHEMA
            resetsdata = 1;
#endif
            expat->final = 1;
            expat->finished = 1;
        }







        break;
        
    case EXPAT_PARSECHANNEL:

        CheckArgs (3,3,2,"<Tcl-Channel>");
        if (expat->parsingState > 1) {
            Tcl_SetResult (interp, "Parser already in use.", TCL_STATIC);







>
>
>
>
>
>
>







843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
        if (expat->final || result != TCL_OK) {
#ifndef TDOM_NO_SCHEMA
            resetsdata = 1;
#endif
            expat->final = 1;
            expat->finished = 1;
        }
#ifndef TDOM_NO_SCHEMA
        if (expat->sdata
            && expat->final == 0
            && expat->sdata->validationState == VALIDATION_READY) {
            expat->sdata->validationState = VALIDATION_STARTED;
        }
#endif
        break;
        
    case EXPAT_PARSECHANNEL:

        CheckArgs (3,3,2,"<Tcl-Channel>");
        if (expat->parsingState > 1) {
            Tcl_SetResult (interp, "Parser already in use.", TCL_STATIC);

Changes to tests/schema.test.

1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
....
1302
1303
1304
1305
1306
1307
1308

















































































1309
1310
1311
1312
1313
1314
1315
    p reset
    lappend result [grammar validate <doc><e1/><e2/><e2/></doc>]
    grammar delete
    p delete
    set result
} {1 {The schema command is busy} VALIDATING 1}

test schema-6.3 {expat parser with -validateCmd} {knownBug} {
    tdom::schema create grammar
    grammar defelement doc {
        element e1
        element e2 *
    }
    foreach e {e1 e2} {
        grammar defelement $e {}
................................................................................
    p configure -final 1
    p reset
    lappend result [grammar validate <doc><e1/><e2/><e2/></doc>]
    grammar delete
    p delete
    set result
} {1 {The schema command is busy} VALIDATING 1}


















































































test schema-7.1 {group} {
    tdom::schema create grammar
    grammar defelement doc {
        element e1
        group ! {
            element e1







|







 







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







1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
....
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
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
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
    p reset
    lappend result [grammar validate <doc><e1/><e2/><e2/></doc>]
    grammar delete
    p delete
    set result
} {1 {The schema command is busy} VALIDATING 1}

test schema-6.3 {expat parser with -validateCmd} {
    tdom::schema create grammar
    grammar defelement doc {
        element e1
        element e2 *
    }
    foreach e {e1 e2} {
        grammar defelement $e {}
................................................................................
    p configure -final 1
    p reset
    lappend result [grammar validate <doc><e1/><e2/><e2/></doc>]
    grammar delete
    p delete
    set result
} {1 {The schema command is busy} VALIDATING 1}

test schema-6.4 {expat parser with -validateCmd} {
    tdom::schema create grammar
    grammar defelement doc {
        element e1
        element e2 *
    }
    foreach e {e1 e2} {
        grammar defelement $e {}
    }
    ::xml::parser p -validateCmd grammar -final 0
    set result [list]
    p parse {<do}
    lappend result [catch {grammar validate <doc><e1/><e2/><e2/></doc>} errMsg]
    lappend result $errMsg
    lappend result [grammar info vstate]
    p parse {c}
    p parse {><e1/></doc>}
    p configure -final 1
    p reset
    lappend result [grammar validate <doc><e1/><e2/><e2/></doc>]
    grammar delete
    p delete
    set result
} {1 {The schema command is busy} VALIDATING 1}

proc elementstart-6.5 {name attList} {
    lappend ::result $name
}

test schema-6.5 {expat parser with -validateCmd} {
    tdom::schema create grammar
    grammar defelement doc {
        element e1
        element e2 *
    }
    foreach e {e1 e2} {
        grammar defelement $e {}
    }
    ::xml::parser p -validateCmd grammar -final 0\
        -elementstartcommand elementstart-6.5
    set result [list]
    p parse {<do}
    p parse {c}
    p parse {><e1/></doc>}
    p configure -final 1
    p reset
    lappend result [grammar validate <doc><e1/><e2/><e2/></doc>]
    grammar delete
    p delete
    set result
} {doc e1 1}

proc elementstart-6.6 {name attList} {
    lappend ::result $name
    if {$name eq "doc"} {
        grammar delete
    }
}

test schema-6.6 {expat parser with -validateCmd} {
    tdom::schema create grammar
    grammar defelement doc {
        element e1
        element e2 *
    }
    foreach e {e1 e2} {
        grammar defelement $e {}
    }
    ::xml::parser p -validateCmd grammar -final 0\
        -elementstartcommand elementstart-6.6
    set result [list]
    p parse {<do}
    p parse {c}
    p parse {><e1/></doc>}
    p configure -final 1
    p reset
    lappend result [info command grammar]
    p delete
    set result
} {doc e1 {}}

test schema-7.1 {group} {
    tdom::schema create grammar
    grammar defelement doc {
        element e1
        group ! {
            element e1