tDOM

Check-in [16e44b5f70]
Login

Check-in [16e44b5f70]

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

Overview
Comment:wip
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: 16e44b5f706583e1be180256be384e1331f571da25a764c7210d3da01d96bcae
User & Date: rolf 2020-03-22 02:04:34.056
Context
2020-03-25
20:17
Save work. check-in: 0e666eae10 user: rolf tags: wip
2020-03-22
02:04
wip check-in: 16e44b5f70 user: rolf tags: wip
2020-03-20
19:27
Save work. check-in: 1c292a129a user: rolf tags: wip
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/schema.c.
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159


1160
1161
1162
1163
1164
1165
1166
1167
        break;
    }
    sdata->currentEvals++;
    rc = Tcl_EvalObjEx (interp, cmdPtr,
                        TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
    sdata->currentEvals--;
    sdata->vaction = 0;
    sdata->vname = NULL;
    sdata->vns = NULL;
    sdata->vtext = NULL;
    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;







|
|









<
<



>
>
|







1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154


1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
        break;
    }
    sdata->currentEvals++;
    rc = Tcl_EvalObjEx (interp, cmdPtr,
                        TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
    sdata->currentEvals--;
    sdata->vaction = 0;
    if (name) sdata->vname = name;
    if (ns) sdata->vns = ns;
    sdata->vtext = NULL;
    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) {


            sdata->recoverFlags |= RECOVER_FLAG_IGNORE;
            return 1;
        } else {
            /* Rewind stack to last match and ignore the just opened
             * Element. */
           finalizeElement (sdata, ac+1);
            sdata->skipDeep = 2;
        }
        break;
    case UNEXPECTED_ELEMENT:
        finalizeElement (sdata, ac+1);
        sdata->skipDeep = 2;
        break;
1692
1693
1694
1695
1696
1697
1698
1699

1700
1701
1702

1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718

    /* The normal case: we're inside the tree */
    /* In case of recovering we unwind the call statck to have updated
     * stack elements, to be able to pretend, we have seen a mandatory
     * element. But with the so reached stack the current open element
     * has to probed again. */
    while (1) {
        rc = matchElementStart (interp, sdata, (char *) namePtr, namespacePtr);

        while (rc == -1) {
            popStack (sdata);
            rc = matchElementStart (interp, sdata, (char *) namePtr, namespacePtr);

        };
        if (rc) {
            DBG(
                fprintf (stderr, "probeElement: element '%s' match\n", name);
                serializeStack (sdata);
                fprintf (stderr, "\n");
                );
            if (sdata->recoverFlags & RECOVER_FLAG_IGNORE) {
                fprintf (stderr, "HIER\n");
                sdata->recoverFlags &= ~RECOVER_FLAG_IGNORE;
                continue;
            }
            return TCL_OK;
        }
        break;
    }







|
>


|
>








<







1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712

1713
1714
1715
1716
1717
1718
1719

    /* The normal case: we're inside the tree */
    /* In case of recovering we unwind the call statck to have updated
     * stack elements, to be able to pretend, we have seen a mandatory
     * element. But with the so reached stack the current open element
     * has to probed again. */
    while (1) {
        rc = matchElementStart (interp, sdata, (char *) namePtr,
                                namespacePtr);
        while (rc == -1) {
            popStack (sdata);
            rc = matchElementStart (interp, sdata, (char *) namePtr,
                                    namespacePtr);
        };
        if (rc) {
            DBG(
                fprintf (stderr, "probeElement: element '%s' match\n", name);
                serializeStack (sdata);
                fprintf (stderr, "\n");
                );
            if (sdata->recoverFlags & RECOVER_FLAG_IGNORE) {

                sdata->recoverFlags &= ~RECOVER_FLAG_IGNORE;
                continue;
            }
            return TCL_OK;
        }
        break;
    }
Changes to tests/schema.test.
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
    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 {







|




|




















>
>


>
>
>
>
>


















|







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
7331
7332
7333
7334
7335
7336
7337
    s delete
    set result
} {b 1}

proc schema-17.22 {scmd errorInfo} {
    global fromReportCmd
    if {[$scmd info vaction] eq "MATCH_ELEMENT_START"} {
        lappend fromReportCmd "matching [$scmd info vaction name]" "expecting [lsort [$scmd info expected]]"
        if {$errorInfo eq "MISSING_ELEMENT"} {
            return ignore
        }
    } else {
        lappend fromReportCmd "END_EVENT expecting [$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/>
        <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>
    }
    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 0/1: 1 a c b c}

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