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

Overview
Comment:More correct handling of interleave content particle in validation state introspection.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: 4c3f653e15e08be8f9c7be0d0fc43a06bb4f86707ac2f9d60796d6d631e12686
User & Date: rolf 2019-10-04 16:13:16
Context
2019-10-05
00:06
Minor work on the documentation. check-in: a5c850a58e user: rolf tags: wip
2019-10-04
16:13
More correct handling of interleave content particle in validation state introspection. check-in: 4c3f653e15 user: rolf tags: wip
12:15
Again, more work on introspection of validation state. check-in: 5dd7e9928d user: rolf tags: wip
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822

2823
2824
2825
2826
2827
2828
2829
....
2901
2902
2903
2904
2905
2906
2907
2908



2909
2910
2911
2912
2913
2914
2915
....
2916
2917
2918
2919
2920
2921
2922



2923
2924
2925
2926
2927
2928
2929
    SchemaData *sdata,
    SchemaValidationStack *se,
    Tcl_Interp *interp,
    Tcl_HashTable *seenCPs,
    Tcl_Obj *rObj
    )
{
    int ac, hm, i, hnew;
    SchemaCP *cp, *ic, *jc;
    SchemaValidationStack *se1;

    getContext (cp, ac, hm);
    if (hm && maxOne(cp->quants[ac])) ac++;
    switch (cp->type) {
    case SCHEMA_CTYPE_INTERLEAVE:
        ac = 0;

        /* Fall through */
    case SCHEMA_CTYPE_NAME:
    case SCHEMA_CTYPE_PATTERN:
        while (ac < cp->nc) {
            if (se->interleaveState
                && se->interleaveState[ac]
                && maxOne (cp->quants[ac])) {
................................................................................
                break;

            case SCHEMA_CTYPE_VIRTUAL:
            case SCHEMA_CTYPE_KEYSPACE:
            case SCHEMA_CTYPE_KEYSPACE_END:
                break;
            }
            if (minOne (cp->quants[ac])) break;



            ac++;
        }
        break;
        
    case SCHEMA_CTYPE_ANY:
    case SCHEMA_CTYPE_CHOICE:
    case SCHEMA_CTYPE_TEXT:
................................................................................
    case SCHEMA_CTYPE_VIRTUAL:
    case SCHEMA_CTYPE_KEYSPACE:
    case SCHEMA_CTYPE_KEYSPACE_END:
        Tcl_Panic ("Invalid CTYPE onto the validation stack!");
    }
    if (cp->type == SCHEMA_CTYPE_NAME) {
        return;



    }
    if (se->down) {
        hm = se->down->hasMatched;
        se->down->hasMatched = 1;
        getFrontExpected (sdata, se->down, interp, seenCPs, rObj);
        se->down->hasMatched = hm;
    }







|








>







 







|
>
>
>







 







>
>
>







2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
....
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
....
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
    SchemaData *sdata,
    SchemaValidationStack *se,
    Tcl_Interp *interp,
    Tcl_HashTable *seenCPs,
    Tcl_Obj *rObj
    )
{
    int ac, hm, i, hnew, mustMatch;
    SchemaCP *cp, *ic, *jc;
    SchemaValidationStack *se1;

    getContext (cp, ac, hm);
    if (hm && maxOne(cp->quants[ac])) ac++;
    switch (cp->type) {
    case SCHEMA_CTYPE_INTERLEAVE:
        ac = 0;
        mustMatch = 0;
        /* Fall through */
    case SCHEMA_CTYPE_NAME:
    case SCHEMA_CTYPE_PATTERN:
        while (ac < cp->nc) {
            if (se->interleaveState
                && se->interleaveState[ac]
                && maxOne (cp->quants[ac])) {
................................................................................
                break;

            case SCHEMA_CTYPE_VIRTUAL:
            case SCHEMA_CTYPE_KEYSPACE:
            case SCHEMA_CTYPE_KEYSPACE_END:
                break;
            }
            if (minOne (cp->quants[ac])) {
                if (cp->type == SCHEMA_CTYPE_INTERLEAVE) mustMatch = 1;
                else break;
            }
            ac++;
        }
        break;
        
    case SCHEMA_CTYPE_ANY:
    case SCHEMA_CTYPE_CHOICE:
    case SCHEMA_CTYPE_TEXT:
................................................................................
    case SCHEMA_CTYPE_VIRTUAL:
    case SCHEMA_CTYPE_KEYSPACE:
    case SCHEMA_CTYPE_KEYSPACE_END:
        Tcl_Panic ("Invalid CTYPE onto the validation stack!");
    }
    if (cp->type == SCHEMA_CTYPE_NAME) {
        return;
    }
    if (cp->type == SCHEMA_CTYPE_INTERLEAVE && mustMatch) {
        return;
    }
    if (se->down) {
        hm = se->down->hasMatched;
        se->down->hasMatched = 1;
        getFrontExpected (sdata, se->down, interp, seenCPs, rObj);
        se->down->hasMatched = hm;
    }

Changes to tests/schema.test.

4881
4882
4883
4884
4885
4886
4887
4888






































4889
4890
4891
4892
4893
4894
4895
        }
    }
    set result ""
    lappend [s validate {<doc><must/></doc>}]
    s delete
    set result
} {c may must}
    






































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







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
        }
    }
    set result ""
    lappend [s validate {<doc><must/></doc>}]
    s delete
    set result
} {c may must}

test schema-17.10 {info frontexpected interleave} {
    set defs {
        {
            interleave {
                element a ?
                element b
                element c ?
            }
            element d
        }
        {
            interleave {
                element a ?
                element b ?
                element c ?
            }
            element d
        }
        {
            interleave ? {
                element a ?
                element b
                element c ?
            }
            element d
        }
    }
    set result [list]
    foreach def $defs {
        tdom::schema s
        s defelement doc $def
        s event start doc
        lappend result {*}[s info frontexpected]
        s delete
    }
    set result
} {a b c a b c a b c d}

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