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

Overview
Comment:Renamed the info method subcommand frontexpected of the validation commands to the hopefully better name nextexpected.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: d889feb189cfdbb5c4957ee67ad0881efe2733df654e4f4d3528f8d63e5711be
User & Date: rolf 2019-10-07 09:33:42
Context
2019-10-08
06:22
Fixed content constrain command "any": respect prefix/ns mapping. More work on info nextexpected. check-in: 223307a111 user: rolf tags: wip
2019-10-07
09:33
Renamed the info method subcommand frontexpected of the validation commands to the hopefully better name nextexpected. check-in: d889feb189 user: rolf tags: wip
2019-10-06
23:40
Save work. check-in: b26625af9b user: rolf tags: wip
Changes

Changes to generic/schema.c.

2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
....
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
....
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
....
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
....
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
....
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
....
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
            || cp->flags & PLACEHOLDER_PATTERN_DEF) continue;
        elmObj = serializeElementName (interp, cp);
        Tcl_ListObjAppendElement (interp, rObj, elmObj);
    }
}

static void
getFrontExpected (
    SchemaData *sdata,
    SchemaValidationStack *se,
    Tcl_Interp *interp,
    Tcl_HashTable *seenCPs,
    Tcl_Obj *rObj
    )
{
................................................................................
                                          serializeElementName (interp, ic));
                break;
            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
                Tcl_CreateHashEntry (seenCPs, ic, &hnew);
                if (hnew) {
                    se1 = getStackElement (sdata, ic);
                    getFrontExpected (sdata, se1, interp, seenCPs, rObj);
                    repoolStackElement (sdata, se1);
                }
                break;

            case SCHEMA_CTYPE_ANY:
                Tcl_ListObjAppendElement (interp, rObj,
                                          Tcl_NewStringObj ("<any>", 5));
................................................................................
                            );
                        break;
                    case SCHEMA_CTYPE_INTERLEAVE:
                    case SCHEMA_CTYPE_PATTERN:
                        Tcl_CreateHashEntry (seenCPs, jc, &hnew);
                        if (hnew) {
                            se1 = getStackElement (sdata, ic);
                            getFrontExpected (sdata, se1, interp, seenCPs,
                                              rObj);
                            repoolStackElement (sdata, se1);
                        }
                        break;
                    case SCHEMA_CTYPE_ANY:
                        Tcl_ListObjAppendElement (
                            interp, rObj, Tcl_NewStringObj ("<any>", 5)
................................................................................
    }
    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;
    }
}

static int
schemaInstanceInfoCmd (
    SchemaData *sdata,
................................................................................
    Tcl_Obj *elmObj;
    void *ns;
    Tcl_Obj *rObj;
    Tcl_HashTable seenCPs;
    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "definedElements", "stack", "toplevel",
        "pastexpected", "frontexpected", "definition", NULL
    };
    enum schemaInstanceInfoMethod {
        m_validationstate, m_vstate, m_definedElements, m_stack, m_toplevel,
        m_pastexpected, m_frontexpected, m_definition
    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside
................................................................................
        if (!sdata->defineToplevel && sdata->currentEvals > 1) {
            SetBooleanResult (0);
        } else {
            SetBooleanResult (1);
        }
        return TCL_OK;

    case m_frontexpected:
        if (sdata->validationState == VALIDATION_ERROR) {
            SetResult ("Validation command in error state.");
            return TCL_ERROR;
        } else if (sdata->validationState == VALIDATION_FINISHED) {
            return TCL_OK;
        }
        if (!sdata->stack) {
................................................................................
                }
            } else {
                definedElements (sdata, interp);
            }
        } else {
            rObj = Tcl_NewObj();
            Tcl_InitHashTable (&seenCPs, TCL_ONE_WORD_KEYS);
            getFrontExpected (sdata, sdata->stack, interp, &seenCPs, rObj);
            Tcl_DeleteHashTable (&seenCPs);
            Tcl_SetObjResult (interp, rObj);
        }
        return TCL_OK;
        
    case m_pastexpected:
        break;







|







 







|







 







|







 







|







 







|



|







 







|







 







|







2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
....
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
....
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
....
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
....
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
....
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
....
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
            || cp->flags & PLACEHOLDER_PATTERN_DEF) continue;
        elmObj = serializeElementName (interp, cp);
        Tcl_ListObjAppendElement (interp, rObj, elmObj);
    }
}

static void
getNextExpected (
    SchemaData *sdata,
    SchemaValidationStack *se,
    Tcl_Interp *interp,
    Tcl_HashTable *seenCPs,
    Tcl_Obj *rObj
    )
{
................................................................................
                                          serializeElementName (interp, ic));
                break;
            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
                Tcl_CreateHashEntry (seenCPs, ic, &hnew);
                if (hnew) {
                    se1 = getStackElement (sdata, ic);
                    getNextExpected (sdata, se1, interp, seenCPs, rObj);
                    repoolStackElement (sdata, se1);
                }
                break;

            case SCHEMA_CTYPE_ANY:
                Tcl_ListObjAppendElement (interp, rObj,
                                          Tcl_NewStringObj ("<any>", 5));
................................................................................
                            );
                        break;
                    case SCHEMA_CTYPE_INTERLEAVE:
                    case SCHEMA_CTYPE_PATTERN:
                        Tcl_CreateHashEntry (seenCPs, jc, &hnew);
                        if (hnew) {
                            se1 = getStackElement (sdata, ic);
                            getNextExpected (sdata, se1, interp, seenCPs,
                                              rObj);
                            repoolStackElement (sdata, se1);
                        }
                        break;
                    case SCHEMA_CTYPE_ANY:
                        Tcl_ListObjAppendElement (
                            interp, rObj, Tcl_NewStringObj ("<any>", 5)
................................................................................
    }
    if (cp->type == SCHEMA_CTYPE_INTERLEAVE && mustMatch) {
        return;
    }
    if (se->down) {
        hm = se->down->hasMatched;
        se->down->hasMatched = 1;
        getNextExpected (sdata, se->down, interp, seenCPs, rObj);
        se->down->hasMatched = hm;
    }
}

static int
schemaInstanceInfoCmd (
    SchemaData *sdata,
................................................................................
    Tcl_Obj *elmObj;
    void *ns;
    Tcl_Obj *rObj;
    Tcl_HashTable seenCPs;
    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "definedElements", "stack", "toplevel",
        "pastexpected", "nextexpected", "definition", NULL
    };
    enum schemaInstanceInfoMethod {
        m_validationstate, m_vstate, m_definedElements, m_stack, m_toplevel,
        m_pastexpected, m_nextexpected, m_definition
    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside
................................................................................
        if (!sdata->defineToplevel && sdata->currentEvals > 1) {
            SetBooleanResult (0);
        } else {
            SetBooleanResult (1);
        }
        return TCL_OK;

    case m_nextexpected:
        if (sdata->validationState == VALIDATION_ERROR) {
            SetResult ("Validation command in error state.");
            return TCL_ERROR;
        } else if (sdata->validationState == VALIDATION_FINISHED) {
            return TCL_OK;
        }
        if (!sdata->stack) {
................................................................................
                }
            } else {
                definedElements (sdata, interp);
            }
        } else {
            rObj = Tcl_NewObj();
            Tcl_InitHashTable (&seenCPs, TCL_ONE_WORD_KEYS);
            getNextExpected (sdata, sdata->stack, interp, &seenCPs, rObj);
            Tcl_DeleteHashTable (&seenCPs);
            Tcl_SetObjResult (interp, rObj);
        }
        return TCL_OK;
        
    case m_pastexpected:
        break;

Changes to tests/schema.test.

4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
....
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
....
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
....
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
....
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
....
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
    set result
} {defelement b {
            element b1 1 text
            element a
            element b2
        }}

test schema-17.5 {info frontexpected} {
    tdom::schema s
    s define {
        defelement doc {
            choice ? {
                element a
                element c
                element b
................................................................................
            }
            element toplevel ?
            element musthave
            element aftermust
        }
    }
    s event start doc
    set result [s info frontexpected]
    s delete
    set result
} {a c b toplevel musthave}

test schema-17.6 {info frontexpected} {
    tdom::schema s
    s prefixns {foo http://foo.bar}
    s define {
        defelement doc {
            choice ? {
                element a
                element c
................................................................................
            namespace foo {
                element musthave
            }
            element aftermust
        }
    }
    s event start doc
    set result [s info frontexpected]
    s delete
    set result
} {a c b toplevel {musthave http://foo.bar}}

test schema-17.7 {info frontexpected} {
    tdom::schema s
    s prefixns {foo http://foo.bar}
    s define {
        defelement doc {
            mixed {
                element a
                element c
................................................................................
            namespace foo {
                element musthave
            }
            element aftermust
        }
    }
    s event start doc
    set result [s info frontexpected]
    s delete
    set result
} {{#text} a c b toplevel {musthave http://foo.bar}}

test schema-17.8 {info frontexpected} {
    tdom::schema s
    s defelement doc {
        choice ? {
            element a
            element c
            element b
        }
        element toplevel ?
        element musthave
        element aftermust
    }
    set result [s info frontexpected]
    s define {
        foreach elm {a b c} {
            defelement $elm {}
        }
    }
    lappend result {*}[lsort [s info frontexpected]]
    s event start doc
    lappend result {*}[s info frontexpected]
    s event start c
    s event end
    lappend result {*}[s info frontexpected]    
    s delete
    set result
} {doc a b c doc a c b toplevel musthave toplevel musthave}

proc schema-17.9 {scmd} {
    global result
    set result [$scmd info frontexpected]
}
                  
test schema-17.9 {info frontexpected from scripted constrain} {
    tdom::schema s
    s define {
        defpattern some {
            element a ?
            group ? {
                element b ?
                tcl schema-17.9
................................................................................
    }
    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 ?
            }
................................................................................
        }
    }
    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 d a b c d}

proc schema-18 {args} {
    lappend ::result {*}$args







|







 







|




|







 







|




|







 







|




|











|





|

|


|






|


|







 







|







 







|







4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
....
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
....
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
....
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
....
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
....
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
    set result
} {defelement b {
            element b1 1 text
            element a
            element b2
        }}

test schema-17.5 {info nextexpected} {
    tdom::schema s
    s define {
        defelement doc {
            choice ? {
                element a
                element c
                element b
................................................................................
            }
            element toplevel ?
            element musthave
            element aftermust
        }
    }
    s event start doc
    set result [s info nextexpected]
    s delete
    set result
} {a c b toplevel musthave}

test schema-17.6 {info nextexpected} {
    tdom::schema s
    s prefixns {foo http://foo.bar}
    s define {
        defelement doc {
            choice ? {
                element a
                element c
................................................................................
            namespace foo {
                element musthave
            }
            element aftermust
        }
    }
    s event start doc
    set result [s info nextexpected]
    s delete
    set result
} {a c b toplevel {musthave http://foo.bar}}

test schema-17.7 {info nextexpected} {
    tdom::schema s
    s prefixns {foo http://foo.bar}
    s define {
        defelement doc {
            mixed {
                element a
                element c
................................................................................
            namespace foo {
                element musthave
            }
            element aftermust
        }
    }
    s event start doc
    set result [s info nextexpected]
    s delete
    set result
} {{#text} a c b toplevel {musthave http://foo.bar}}

test schema-17.8 {info nextexpected} {
    tdom::schema s
    s defelement doc {
        choice ? {
            element a
            element c
            element b
        }
        element toplevel ?
        element musthave
        element aftermust
    }
    set result [s info nextexpected]
    s define {
        foreach elm {a b c} {
            defelement $elm {}
        }
    }
    lappend result {*}[lsort [s info nextexpected]]
    s event start doc
    lappend result {*}[s info nextexpected]
    s event start c
    s event end
    lappend result {*}[s info nextexpected]    
    s delete
    set result
} {doc a b c doc a c b toplevel musthave toplevel musthave}

proc schema-17.9 {scmd} {
    global result
    set result [$scmd info nextexpected]
}
                  
test schema-17.9 {info nextexpected from scripted constrain} {
    tdom::schema s
    s define {
        defpattern some {
            element a ?
            group ? {
                element b ?
                tcl schema-17.9
................................................................................
    }
    set result ""
    lappend [s validate {<doc><must/></doc>}]
    s delete
    set result
} {c may must}

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

proc schema-18 {args} {
    lappend ::result {*}$args