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

Overview
Comment:This returns even something to script level.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: c8b0062672aa966b44dd84cc7e79f673532ef55203359140feb7ece7c136e55b
User & Date: rolf 2019-10-03 02:18:37
Context
2019-10-03
02:23
Added another test. check-in: 05cfa07ebf user: rolf tags: wip
02:18
This returns even something to script level. check-in: c8b0062672 user: rolf tags: wip
2019-10-01
23:10
wip check-in: 1f46cc97c2 user: rolf tags: wip
Changes

Changes to generic/schema.c.

737
738
739
740
741
742
743



















744
745
746
747
748
749
750
...
763
764
765
766
767
768
769










770
771
772
773
774
775
776
....
2756
2757
2758
2759
2760
2761
2762

2763
2764

2765
2766
2767
2768
2769

2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788

2789
2790
2791
2792






2793
2794
2795
2796
2797
2798
2799
2800
2801





2802
2803
2804
2805
2806
2807
2808
....
2818
2819
2820
2821
2822
2823
2824
2825
2826




2827

2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
....
2848
2849
2850
2851
2852
2853
2854


2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870


2871
2872
2873
2874
2875
2876
2877
2878
....
2882
2883
2884
2885
2886
2887
2888

2889
2890
2891
2892
2893
2894
2895
....
2994
2995
2996
2997
2998
2999
3000
3001

3002


3003
3004
3005
3006
3007
3008
3009
        sdata->cp->nc++;
    }
    if (savedCP) {
        sdata->cp = savedCP;
        sdata->contentSize = savedContenSize;
    }
}




















static void
pushToStack (
    SchemaData *sdata,
    SchemaCP *pattern
    )
{
................................................................................
    stackElm->pattern = pattern;
    if (pattern->type == SCHEMA_CTYPE_INTERLEAVE) {
        stackElm->interleaveState = MALLOC (sizeof (int) * pattern->nc);
        memset (stackElm->interleaveState, 0, sizeof (int) * pattern->nc);
    }
    sdata->stack = stackElm;
}











static void
popStack (
    SchemaData *sdata
    )
{
    SchemaValidationStack *se;
................................................................................
        elmObj = serializeElementName (interp, cp);
        Tcl_ListObjAppendElement (interp, rObj, elmObj);
    }
}

static void
getFrontExpected (

    SchemaValidationStack *se,
    Tcl_Interp *interp,

    Tcl_Obj *rObj
    )
{
    int ac, hm, i;
    SchemaCP *cp, *ic, *jc;


    getContext (cp, ac, hm);
    if (hasMatched(cp->quants[ac], hm)) {
        ac++;
        hm = 0;
    }
    switch (cp->type) {
    case SCHEMA_CTYPE_INTERLEAVE:
        if (se->interleaveState) {
            for (i = 0; i < cp->nc; i++) {
                if (se->interleaveState[i] && maxOne (cp->quants[i])) {
                    continue;
                }
                
            }
            
            
            break;
        }

        /* Fall through */
    case SCHEMA_CTYPE_NAME:
    case SCHEMA_CTYPE_PATTERN:
        while (ac < cp->nc) {






            ic = cp->content[ac];
            switch (ic->type) {
            case SCHEMA_CTYPE_NAME:
                Tcl_ListObjAppendElement (interp, rObj,
                                          serializeElementName (interp, ic));
                break;
            case SCHEMA_CTYPE_INTERLEAVE:
            case SCHEMA_CTYPE_PATTERN:
                /* Mumble mumble */





                break;

            case SCHEMA_CTYPE_ANY:
                Tcl_ListObjAppendElement (interp, rObj,
                                          Tcl_NewStringObj ("<any>", 5));
                break;

................................................................................
                    case SCHEMA_CTYPE_NAME:
                        Tcl_ListObjAppendElement (
                            interp, rObj, serializeElementName (interp, jc)
                            );
                        break;
                    case SCHEMA_CTYPE_INTERLEAVE:
                    case SCHEMA_CTYPE_PATTERN:
                        /* Mumble mumble */
                        break;






                    case SCHEMA_CTYPE_ANY:
                        Tcl_ListObjAppendElement (
                            interp, rObj, Tcl_NewStringObj ("<any>", 5)
                            );
                        break;

                    case SCHEMA_CTYPE_TEXT:
                        Tcl_ListObjAppendElement (
                            interp, rObj, Tcl_NewStringObj ("#text", 5)
                            );
                        break;
                    case SCHEMA_CTYPE_CHOICE:
                        Tcl_Panic ("MIXED or CHOICE child of MIXED or CHOICE");
................................................................................
                break;

            case SCHEMA_CTYPE_VIRTUAL:
            case SCHEMA_CTYPE_KEYSPACE:
            case SCHEMA_CTYPE_KEYSPACE_END:
                break;
            }


                    
        }
        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;
    }


    
}

static int
schemaInstanceInfoCmd (
    SchemaData *sdata,
    Tcl_Interp *interp,
    int objc,
................................................................................
    int methodIndex;
    Tcl_HashEntry *h;
    SchemaCP *cp;
    SchemaValidationStack *se;
    Tcl_Obj *elmObj;
    void *ns;
    Tcl_Obj *rObj;

    
    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,
................................................................................
                if (sdata->startNamespace) {
                    Tcl_AppendElement (interp, sdata->startNamespace);
                }
            } else {
                definedElements (sdata, interp);
            }
        } else {
            rObj = Tcl_GetObjResult (interp);

            getFrontExpected (sdata->stack, interp, rObj);


        }
        return TCL_OK;
        
    case m_pastexpected:
        break;
        
    case m_definition:







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>







 







>


>



|

>


|
<
<
<


<
<
<
<
<
<
<
<
<
<
<
>




>
>
>
>
>
>








|
>
>
>
>
>







 







|
|
>
>
>
>
|
>





<







 







>
>
|
<

<












>
>
|







 







>







 







|
>
|
>
>







737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
...
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
....
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804



2805
2806











2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
....
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867

2868
2869
2870
2871
2872
2873
2874
....
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891

2892

2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
....
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
....
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
        sdata->cp->nc++;
    }
    if (savedCP) {
        sdata->cp = savedCP;
        sdata->contentSize = savedContenSize;
    }
}

static SchemaValidationStack * 
getStackElement (
    SchemaData *sdata,
    SchemaCP *pattern
    )
{
    SchemaValidationStack *stackElm;

    if (sdata->stackPool) {
        stackElm = sdata->stackPool;
        sdata->stackPool = stackElm->down;
    } else {
        stackElm = TMALLOC (SchemaValidationStack);
    }
    memset (stackElm, 0, sizeof (SchemaValidationStack));
    stackElm->pattern = pattern;
    return stackElm;
}

static void
pushToStack (
    SchemaData *sdata,
    SchemaCP *pattern
    )
{
................................................................................
    stackElm->pattern = pattern;
    if (pattern->type == SCHEMA_CTYPE_INTERLEAVE) {
        stackElm->interleaveState = MALLOC (sizeof (int) * pattern->nc);
        memset (stackElm->interleaveState, 0, sizeof (int) * pattern->nc);
    }
    sdata->stack = stackElm;
}

static void
repoolStackElement (
    SchemaData *sdata,
    SchemaValidationStack *se
    ) 
{
    se->down = sdata->stackPool;
    sdata->stackPool = se;
}

static void
popStack (
    SchemaData *sdata
    )
{
    SchemaValidationStack *se;
................................................................................
        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
    )
{
    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])) {
                ac++;
                continue;
            }
            ic = cp->content[ac];
            switch (ic->type) {
            case SCHEMA_CTYPE_NAME:
                Tcl_ListObjAppendElement (interp, 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_NAME:
                        Tcl_ListObjAppendElement (
                            interp, rObj, serializeElementName (interp, jc)
                            );
                        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)
                            );
                        break;

                    case SCHEMA_CTYPE_TEXT:
                        Tcl_ListObjAppendElement (
                            interp, rObj, Tcl_NewStringObj ("#text", 5)
                            );
                        break;
                    case SCHEMA_CTYPE_CHOICE:
                        Tcl_Panic ("MIXED or CHOICE child of MIXED or CHOICE");
................................................................................
                break;

            case SCHEMA_CTYPE_VIRTUAL:
            case SCHEMA_CTYPE_KEYSPACE:
            case SCHEMA_CTYPE_KEYSPACE_END:
                break;
            }
            if (minOne (cp->quants[ac])) return;
            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) {
        getFrontExpected (sdata, se->down, interp, seenCPs, rObj);
    }
}

static int
schemaInstanceInfoCmd (
    SchemaData *sdata,
    Tcl_Interp *interp,
    int objc,
................................................................................
    int methodIndex;
    Tcl_HashEntry *h;
    SchemaCP *cp;
    SchemaValidationStack *se;
    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,
................................................................................
                if (sdata->startNamespace) {
                    Tcl_AppendElement (interp, sdata->startNamespace);
                }
            } 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;
        
    case m_definition:

Changes to tests/schema.test.

4759
4760
4761
4762
4763
4764
4765




















4766
4767
4768
4769
4770
4771
4772
    s delete
    set result
} {defelement b {
            element b1 1 text
            element a
            element b2
        }}





















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







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
    s delete
    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}

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