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

Overview
Comment:Fixed element start event in case of a complex content as child of interleave which isn't optional by quant but is because all of its constituents are optional.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 748fb8a4324c7cf89e5595ac209860cb706fd6e685ab0a249fb5dabc27b0ce7f
User & Date: rolf 2020-05-15 01:34:59
Context
2020-05-20
14:01
Fixed gross bug in info expected, which just was not triggered so far. check-in: 910d0dbb65 user: rolf tags: schema
2020-05-16
15:31
wip check-in: 8aa4152961 user: rolf tags: tmp
2020-05-15
01:34
Fixed element start event in case of a complex content as child of interleave which isn't optional by quant but is because all of its constituents are optional. check-in: 748fb8a432 user: rolf tags: schema
2020-05-14
23:12
There is still a bit work left to do in checkElementEnd. check-in: 9f3926e748 user: rolf tags: schema
Changes

Changes to generic/schema.c.

1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
....
1542
1543
1544
1545
1546
1547
1548

1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560


1561
1562
1563
1564
1565
1566
1567
....
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619

1620
1621
1622
1623
1624
1625
1626
    Tcl_Interp *interp,
    SchemaData *sdata,
    char *name,
    char *namespace
    )
{
    SchemaCP *cp, *candidate, *icp;
    int hm, ac, i, mayskip, rc;
    int isName = 0;
    SchemaValidationStack *se;
    Tcl_HashEntry *h;

    if (!sdata->stack) return 0;
    se = sdata->stack;
    getContext (cp, ac, hm);
................................................................................
    case SCHEMA_CTYPE_ANY:
        /* Never pushed onto stack */
        Tcl_Panic ("Invalid CTYPE onto the validation stack!");

    case SCHEMA_CTYPE_INTERLEAVE:
        mayskip = 1;
        for (i = 0; i < cp->nc; i++) {

            if (se->interleaveState[i]) {
                if (maxOne (cp->quants[i])) continue;
            } else {
                if (minOne (cp->quants[i])) mayskip = 0;
            }
            icp = cp->content[i];
            switch (icp->type) {
            case SCHEMA_CTYPE_TEXT:
                if (icp->nc) {
                    if (!checkText (interp, icp, "")) {
                        mayskip = 0;
                    }


                }
                break;

            case SCHEMA_CTYPE_ANY:
                if (icp->namespace && icp->namespace == namespace) {
                    break;
                }
................................................................................
                break;

            case SCHEMA_CTYPE_CHOICE:
                Tcl_Panic ("MIXED or CHOICE child of INTERLEAVE");

            case SCHEMA_CTYPE_PATTERN:
                if (recursivePattern (se, icp)) {
                    mayskip = 1;
                    continue;
                }
                /* fall throu */
            case SCHEMA_CTYPE_INTERLEAVE:
                pushToStack (sdata, icp);
                rc = matchElementStart (interp, sdata, name, namespace);
                if (rc == 1) {
                    if (!(sdata->recoverFlags & RECOVER_FLAG_REWIND)) {
                        se->hasMatched = 1;
                        se->interleaveState[i] = 1;
                    }
                    return 1;
                }
                popStack (sdata);
                if (mayskip && rc != -1) mayskip = 0;
                break;

            case SCHEMA_CTYPE_VIRTUAL:
                Tcl_Panic ("Virtual constraint child of INTERLEAVE");
                break;

            case SCHEMA_CTYPE_KEYSPACE_END:
            case SCHEMA_CTYPE_KEYSPACE:
                Tcl_Panic ("Keyspace constraint child of INTERLEAVE");
                break;

            }

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







|







 







>


<
<





|
|

>
>







 







|
|













|












>







1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
....
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551


1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
....
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
    Tcl_Interp *interp,
    SchemaData *sdata,
    char *name,
    char *namespace
    )
{
    SchemaCP *cp, *candidate, *icp;
    int hm, ac, i, mayskip, thismayskip, rc;
    int isName = 0;
    SchemaValidationStack *se;
    Tcl_HashEntry *h;

    if (!sdata->stack) return 0;
    se = sdata->stack;
    getContext (cp, ac, hm);
................................................................................
    case SCHEMA_CTYPE_ANY:
        /* Never pushed onto stack */
        Tcl_Panic ("Invalid CTYPE onto the validation stack!");

    case SCHEMA_CTYPE_INTERLEAVE:
        mayskip = 1;
        for (i = 0; i < cp->nc; i++) {
            thismayskip = 0;
            if (se->interleaveState[i]) {
                if (maxOne (cp->quants[i])) continue;


            }
            icp = cp->content[i];
            switch (icp->type) {
            case SCHEMA_CTYPE_TEXT:
                if (icp->nc) {
                    if (checkText (interp, icp, "")) {
                        thismayskip = 1;
                    }
                } else {
                    thismayskip = 1;
                }
                break;

            case SCHEMA_CTYPE_ANY:
                if (icp->namespace && icp->namespace == namespace) {
                    break;
                }
................................................................................
                break;

            case SCHEMA_CTYPE_CHOICE:
                Tcl_Panic ("MIXED or CHOICE child of INTERLEAVE");

            case SCHEMA_CTYPE_PATTERN:
                if (recursivePattern (se, icp)) {
                    thismayskip = 1;
                    break;
                }
                /* fall throu */
            case SCHEMA_CTYPE_INTERLEAVE:
                pushToStack (sdata, icp);
                rc = matchElementStart (interp, sdata, name, namespace);
                if (rc == 1) {
                    if (!(sdata->recoverFlags & RECOVER_FLAG_REWIND)) {
                        se->hasMatched = 1;
                        se->interleaveState[i] = 1;
                    }
                    return 1;
                }
                popStack (sdata);
                if (rc == -1) thismayskip = 1;
                break;

            case SCHEMA_CTYPE_VIRTUAL:
                Tcl_Panic ("Virtual constraint child of INTERLEAVE");
                break;

            case SCHEMA_CTYPE_KEYSPACE_END:
            case SCHEMA_CTYPE_KEYSPACE:
                Tcl_Panic ("Keyspace constraint child of INTERLEAVE");
                break;

            }
            if (!thismayskip && minOne (cp->quants[i])) mayskip = 0;
        }
        if (mayskip) break;
        if (recover (interp, sdata, MISSING_ELEMENT_MATCH_START, name,
                     namespace, NULL, cp->nc)) {
            return 1;
        }
        return 0;

Changes to tests/schema.test.

6423
6424
6425
6426
6427
6428
6429


































































6430
6431
6432
6433
6434
6435
6436
        <doc><c/><a/><b/></doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {1 1 1 1 1 1 1 0 1}



































































test schema-17.1 {info} {
    tdom::schema s
    s define {
        foreach e {a b1 b11 b2 c} {
            defelement $e {}
        }







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







6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
        <doc><c/><a/><b/></doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {1 1 1 1 1 1 1 0 1}

test schema-16.19 {interleave with all content cp optional} {
    tdom::schema s
    s defelement doc {
        interleave {
            element a ?
            element b ?
            choice {
                element c ?
                element c1 ?
                element c2 ?
            }
        }
        element d
    }
    set result [list]
    foreach xml {
        <doc/>
        <doc><a/><d/></doc>
        <doc><b/><d/></doc>
        <doc><c/><d/></doc>
        <doc><a/><c/><d/></doc>
        <doc><b/><c/><d/></doc>
        <doc><c/><a/><d/></doc>
        <doc><c/><a/><b/><d/></doc>
        <doc><c/><a/><b/></doc>
        <doc><d/></doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 1 1 1 1 1 1 1 0 1}

test schema-16.20 {interleave with all content cp optional} {
    tdom::schema s
    s defelement doc {
        interleave {
            element a ?
            element b ?
            group {
                element c ?
                element c1 ?
                element c2 ?
            }
        }
        element d
    }
    set result [list]
    foreach xml {
        <doc/>
        <doc><a/><d/></doc>
        <doc><b/><d/></doc>
        <doc><c/><d/></doc>
        <doc><a/><c/><d/></doc>
        <doc><b/><c/><d/></doc>
        <doc><c/><a/><d/></doc>
        <doc><c/><a/><b/><d/></doc>
        <doc><c/><a/><b/></doc>
        <doc><d/></doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 1 1 1 1 1 1 1 0 1}

test schema-17.1 {info} {
    tdom::schema s
    s define {
        foreach e {a b1 b11 b2 c} {
            defelement $e {}
        }