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

Overview
Comment:Added a recoverFlags element to the schema data structure and reworked the rewind flag int to be a recoverFlags flag. We will need more of them.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: 02d5ffc9b5689a642cba9d48925e62e3d136565f01e5add729df37dee8b31595
User & Date: rolf 2020-03-19 01:09:01
Context
2020-03-19
02:15
Made the default recover behaviour at element end the same as for element start: skip and continue at the sibling of the current subtree. Closed-Leaf check-in: 0037ce9df3 user: rolf tags: wip
01:09
Added a recoverFlags element to the schema data structure and reworked the rewind flag int to be a recoverFlags flag. We will need more of them. check-in: 02d5ffc9b5 user: rolf tags: wip
2020-03-16
00:38
Save work. check-in: d70281b9c7 user: rolf tags: wip
Changes

Changes to generic/schema.c.

163
164
165
166
167
168
169
170








171
172
173
174
175
176
177
...
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
....
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
....
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
    "INVALID_KEYREF",
    "UNKNOWN_ROOT_ELEMENT",
    "UNKOWN_GLOBAL_ID",
    "UNKOWN_ID",
    "INVALID_ATTRIBUTE_VALUE",
    "INVALID_VALUE"
};
    








/*----------------------------------------------------------------------------
|   domKeyConstraint related flage
|
\---------------------------------------------------------------------------*/

#define DKC_FLAG_IGNORE_EMPTY_FIELD_SET 1
#define DKC_FLAG_BOOLEAN 2
................................................................................
#define CHECK_EVAL                                                      \
    if (sdata->currentEvals) {                                          \
        SetResult ("This method is not allowed in nested evaluation");  \
        return TCL_ERROR;                                               \
    }

#define CHECK_REWIND                                                    \
    if (sdata->rewind) {                                                \
        rewindStack (sdata);                                            \
        sdata->rewind = 0;                                              \
    }                                                                   \

#define REMEMBER_PATTERN(pattern)                                       \
    if (sdata->numPatternList == sdata->patternListSize) {              \
        sdata->patternList = (SchemaCP **) REALLOC (                    \
            sdata->patternList,                                         \
            sizeof (SchemaCP*) * sdata->patternListSize * 2);           \
................................................................................
    if (hm && maxOne (cp->quants[ac])) {          \
        ac += + 1;                                \
        hm = 0;                                   \
    }                                             \


#define updateStack(sdata,cp,ac)                  \
    if (!sdata->rewind) {                         \
        se->activeChild = ac;                     \
        se->hasMatched = 1;                       \
    }                                             \
    
static SchemaCP*
initSchemaCP (
    Schema_CP_Type type,
................................................................................
    switch (errorType) {
    case MISSING_ELEMENT_MATCH_START:
    case UNEXPECTED_ELEMENT:
        finalizeElement (sdata, ac+1);
        sdata->skipDeep = 2;
        break;
    case UNEXPECTED_TEXT:
        sdata->rewind = 1;
        break;
    case DOM_KEYCONSTRAINT:
    case DOM_XPATH_BOOLEAN:
    case MISSING_ATTRIBUTE:
    case MISSING_ELEMENT_MATCH_END:
    case MISSING_TEXT_MATCH_START:
    case MISSING_TEXT_MATCH_END:
................................................................................
    Tcl_HashEntry *h;
    Tcl_HashSearch search;
    SchemaDocKey *dk;
    SchemaKeySpace *ks;

    while (sdata->stack) popStack (sdata);
    while (sdata->lastMatchse) popFromStack (sdata, &sdata->lastMatchse);
    sdata->rewind = 0;
    sdata->validationState = VALIDATION_READY;
    sdata->skipDeep = 0;
    sdata->evalError = 0;
    sdata->vaction = 0;
    sdata->vname = NULL;
    sdata->vns = NULL;
    sdata->vtext = NULL;







|
>
>
>
>
>
>
>
>







 







|

|







 







|







 







|







 







|







163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
...
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
...
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
....
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
....
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
    "INVALID_KEYREF",
    "UNKNOWN_ROOT_ELEMENT",
    "UNKOWN_GLOBAL_ID",
    "UNKOWN_ID",
    "INVALID_ATTRIBUTE_VALUE",
    "INVALID_VALUE"
};

/*----------------------------------------------------------------------------
|   Recover related flage
|
\---------------------------------------------------------------------------*/

#define RECOVER_FLAG_REWIND 1
#define RECOVER_FLAG_DONT_REPORT 2

/*----------------------------------------------------------------------------
|   domKeyConstraint related flage
|
\---------------------------------------------------------------------------*/

#define DKC_FLAG_IGNORE_EMPTY_FIELD_SET 1
#define DKC_FLAG_BOOLEAN 2
................................................................................
#define CHECK_EVAL                                                      \
    if (sdata->currentEvals) {                                          \
        SetResult ("This method is not allowed in nested evaluation");  \
        return TCL_ERROR;                                               \
    }

#define CHECK_REWIND                                                    \
    if (sdata->recoverFlags & RECOVER_FLAG_REWIND) {                    \
        rewindStack (sdata);                                            \
        sdata->recoverFlags &= ~RECOVER_FLAG_REWIND;                    \
    }                                                                   \

#define REMEMBER_PATTERN(pattern)                                       \
    if (sdata->numPatternList == sdata->patternListSize) {              \
        sdata->patternList = (SchemaCP **) REALLOC (                    \
            sdata->patternList,                                         \
            sizeof (SchemaCP*) * sdata->patternListSize * 2);           \
................................................................................
    if (hm && maxOne (cp->quants[ac])) {          \
        ac += + 1;                                \
        hm = 0;                                   \
    }                                             \


#define updateStack(sdata,cp,ac)                  \
    if (!(sdata->recoverFlags & RECOVER_FLAG_REWIND)) { \
        se->activeChild = ac;                     \
        se->hasMatched = 1;                       \
    }                                             \
    
static SchemaCP*
initSchemaCP (
    Schema_CP_Type type,
................................................................................
    switch (errorType) {
    case MISSING_ELEMENT_MATCH_START:
    case UNEXPECTED_ELEMENT:
        finalizeElement (sdata, ac+1);
        sdata->skipDeep = 2;
        break;
    case UNEXPECTED_TEXT:
        sdata->recoverFlags |= RECOVER_FLAG_REWIND;
        break;
    case DOM_KEYCONSTRAINT:
    case DOM_XPATH_BOOLEAN:
    case MISSING_ATTRIBUTE:
    case MISSING_ELEMENT_MATCH_END:
    case MISSING_TEXT_MATCH_START:
    case MISSING_TEXT_MATCH_END:
................................................................................
    Tcl_HashEntry *h;
    Tcl_HashSearch search;
    SchemaDocKey *dk;
    SchemaKeySpace *ks;

    while (sdata->stack) popStack (sdata);
    while (sdata->lastMatchse) popFromStack (sdata, &sdata->lastMatchse);
    sdata->recoverFlags = 0;
    sdata->validationState = VALIDATION_READY;
    sdata->skipDeep = 0;
    sdata->evalError = 0;
    sdata->vaction = 0;
    sdata->vname = NULL;
    sdata->vns = NULL;
    sdata->vtext = NULL;

Changes to generic/schema.h.

161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
    SchemaQuant *quants;
    int       inuse;
    int       currentEvals;
    int       cleanupAfterUse;
    int       evalError;
    Tcl_Obj  *reportCmd;
    SchemaValidationStack *lastMatchse;
    int       rewind;
    Tcl_Obj **evalStub;
    Tcl_Obj **textStub;
    char *currentNamespace;
    int   defineToplevel;
    int   isTextConstraint;
    int   isAttributeConstaint;
    SchemaCP *cp;







|







161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
    SchemaQuant *quants;
    int       inuse;
    int       currentEvals;
    int       cleanupAfterUse;
    int       evalError;
    Tcl_Obj  *reportCmd;
    SchemaValidationStack *lastMatchse;
    int       recoverFlags;
    Tcl_Obj **evalStub;
    Tcl_Obj **textStub;
    char *currentNamespace;
    int   defineToplevel;
    int   isTextConstraint;
    int   isAttributeConstaint;
    SchemaCP *cp;

Changes to tests/schema.test.

7732
7733
7734
7735
7736
7737
7738




7739
7740
7741
7742
7743
7744
7745
....
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {}





test schema-18.18 {missing element at MATCH_ELEMENT_END} {
    set defs {
        {
            defelement doc {
                ref r1
            }
            defpattern r1 {
................................................................................
                element b ! {}
            }
        }
    }
    set result [list]
    foreach def $defs {
        tdom::schema s
        s reportcmd appendtoresult
        s define $def
        lappend result [s validate {<doc/>}]
        s delete
    }
    set result
} {}








>
>
>
>







 







|







7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
....
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {}

proc schema-18.18 {scmd errortype} {
    lappend ::result $errortype
    lappend ::result [$scmd info expected]
}
test schema-18.18 {missing element at MATCH_ELEMENT_END} {
    set defs {
        {
            defelement doc {
                ref r1
            }
            defpattern r1 {
................................................................................
                element b ! {}
            }
        }
    }
    set result [list]
    foreach def $defs {
        tdom::schema s
        s reportcmd schema-18.18
        s define $def
        lappend result [s validate {<doc/>}]
        s delete
    }
    set result
} {}