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

Overview
Comment:The SchemaValidationStack struct element activeChild (which turned into a misnomer by the last moves) - together with the hasMatched element - now gives the position of the last matched content particle (was the child to start look at for the next event).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: e795f2b9f0180079d39620dfe7ab5431faba6f6f8d9904199ac47196557d8d94
User & Date: rolf 2019-11-02 01:29:03
Context
2019-11-04
00:24
Save work. check-in: d2f12cc8d4 user: rolf tags: wip
2019-11-02
01:29
The SchemaValidationStack struct element activeChild (which turned into a misnomer by the last moves) - together with the hasMatched element - now gives the position of the last matched content particle (was the child to start look at for the next event). check-in: e795f2b9f0 user: rolf tags: wip
2019-11-01
15:42
Added more fine print towards being able to calculate the set of possible (expected) events in case of validation error. check-in: 6a02d5bab5 user: rolf tags: wip
Changes

Changes to generic/schema.c.

301
302
303
304
305
306
307
308
309
310
311




312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
...
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
....
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
#define hasMatched(quant,hm) \
    (hm) == 0 ?  mayMiss(quant) :  1

#define mustMatch(quant,hm) \
    (hm) == 0 ? minOne(quant) : 0


#define getContext(cp, ac, hm)        \
    cp = se->pattern;                 \
    ac = se->activeChild;             \
    hm = se->hasMatched;






#define updateStack(se,cp,ac)                     \
    se->startChild = ac;                          \
    if (maxOne (cp->quants[ac])) {                \
        se->activeChild = ac + 1;                 \
        se->hasMatched = 0;                       \
    } else {                                      \
        se->activeChild = ac;                     \
        se->hasMatched = 1;                       \
    }

static SchemaCP*
initSchemaCP (
    Schema_CP_Type type,
    void *namespace,
    char *name
    )
................................................................................
            nextse = se->down;
            repoolStackElement (sdata, se);
            se = nextse;
        }
        sdata->lastMatchse = NULL;
    }
    se = getStackElement (sdata, pattern);
    /* if (sdata->stack) sdata->stack->activeChild = ac; */
    se->down = sdata->stack;
    if (pattern->type == SCHEMA_CTYPE_INTERLEAVE) {
        se->interleaveState = MALLOC (sizeof (int) * pattern->nc);
        memset (se->interleaveState, 0, sizeof (int) * pattern->nc);
    }
    sdata->stack = se;
}
................................................................................
            }
            pattern = pattern->next;
        }
    } else {
        pattern = NULL;
    }

    if (sdata->stack) {
        SchemaValidationStack *se;
        se = sdata->stack;
        if (se->pattern->type == SCHEMA_CTYPE_NAME
            && se->activeChild >= se->pattern->nc) {
            if (recover (interp, sdata, UNEXPECTED_ELEMENT, name, namespace,
                         NULL, se->pattern->nc)) {
                return TCL_OK;
            }
            SetResult ("Unexpected child element \"");
            if (namespacePtr) {
                Tcl_AppendResult (interp, namespacePtr, ":", NULL);
            }
            Tcl_AppendResult (interp, name, "\" for element \"", NULL);
            if (se->pattern->namespace) {
                Tcl_AppendResult (interp, namespace, ":", NULL);
            }
            Tcl_AppendResult (interp, name, "\"", NULL);
            return TCL_ERROR;
        }
    } else {
        sdata->validationState = VALIDATION_STARTED;
        if (!pattern) {
            if (recover (interp, sdata, UNKNOWN_ROOT_ELEMENT, name, namespace,
                         NULL, 0)) {
                sdata->skipDeep = 1;
                return TCL_OK;
            }







|
|
|
|
>
>
>
>



<
<
<
<
<
|
|
<







 







<







 







|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318





319
320

321
322
323
324
325
326
327
...
853
854
855
856
857
858
859

860
861
862
863
864
865
866
....
1550
1551
1552
1553
1554
1555
1556
1557




















1558
1559
1560
1561
1562
1563
1564
#define hasMatched(quant,hm) \
    (hm) == 0 ?  mayMiss(quant) :  1

#define mustMatch(quant,hm) \
    (hm) == 0 ? minOne(quant) : 0


#define getContext(cp, ac, hm)                    \
    cp = se->pattern;                             \
    ac = se->activeChild;                         \
    hm = se->hasMatched;                          \
    if (hm && maxOne (cp->quants[ac])) {          \
        ac += + 1;                                \
        hm = 0;                                   \
    }                                             \


#define updateStack(se,cp,ac)                     \





    se->activeChild = ac;                         \
    se->hasMatched = 1;                           \


static SchemaCP*
initSchemaCP (
    Schema_CP_Type type,
    void *namespace,
    char *name
    )
................................................................................
            nextse = se->down;
            repoolStackElement (sdata, se);
            se = nextse;
        }
        sdata->lastMatchse = NULL;
    }
    se = getStackElement (sdata, pattern);

    se->down = sdata->stack;
    if (pattern->type == SCHEMA_CTYPE_INTERLEAVE) {
        se->interleaveState = MALLOC (sizeof (int) * pattern->nc);
        memset (se->interleaveState, 0, sizeof (int) * pattern->nc);
    }
    sdata->stack = se;
}
................................................................................
            }
            pattern = pattern->next;
        }
    } else {
        pattern = NULL;
    }

    if (!sdata->stack) {




















        sdata->validationState = VALIDATION_STARTED;
        if (!pattern) {
            if (recover (interp, sdata, UNKNOWN_ROOT_ELEMENT, name, namespace,
                         NULL, 0)) {
                sdata->skipDeep = 1;
                return TCL_OK;
            }

Changes to generic/schema.h.

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
} SchemaCP;

typedef struct SchemaValidationStack
{
    SchemaCP *pattern;
    struct SchemaValidationStack *next;
    struct SchemaValidationStack *down;
    int               startChild;
    int               activeChild;
    int               hasMatched;
    int              *interleaveState;
} SchemaValidationStack;

typedef enum {
    VALIDATION_READY,







<







113
114
115
116
117
118
119

120
121
122
123
124
125
126
} SchemaCP;

typedef struct SchemaValidationStack
{
    SchemaCP *pattern;
    struct SchemaValidationStack *next;
    struct SchemaValidationStack *down;

    int               activeChild;
    int               hasMatched;
    int              *interleaveState;
} SchemaValidationStack;

typedef enum {
    VALIDATION_READY,

Changes to tests/schema.test.

2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
</addressBook>        
    }]
    set result [s domvalidate $doc errMsg]
    lappend result $errMsg
    $doc delete
    s delete
    set result
} {0 {Unexpected child element "some" for element "some"}}

test schema-12.3 {domvalidate w/ attribute} {
    tdom::schema s
    s define {
        defelement doc {
            attribute type {fixed "1.2"}
            element a







|







2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
</addressBook>        
    }]
    set result [s domvalidate $doc errMsg]
    lappend result $errMsg
    $doc delete
    s delete
    set result
} {0 {Element "some" doesn't match}}

test schema-12.3 {domvalidate w/ attribute} {
    tdom::schema s
    s define {
        defelement doc {
            attribute type {fixed "1.2"}
            element a