tDOM

Check-in [3bf5b1e10d]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:Still wip.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: 3bf5b1e10dedee8faf5cc9b1b05ab0d0b9c52f078dadf46ce63acedde860f133
User & Date: rolf 2019-03-20 16:00:12
Context
2019-03-23
15:20
Wip (not well working inbetween state). check-in: 0da31f4fcb user: rolf tags: wip
2019-03-20
16:00
Still wip. check-in: 3bf5b1e10d user: rolf tags: wip
2019-03-13
01:47
Fix overeager cleanup of virtual constraints. check-in: abd9fe81b1 user: rolf tags: wip
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

251
252
253
254
255
256
257


258
259
260
261
262
263
264
...
504
505
506
507
508
509
510



511
512
513
514
515
516
517
...
708
709
710
711
712
713
714

715
716
717
718
719
720
721
...
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
...
911
912
913
914
915
916
917






918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
    rObj = Tcl_NewObj();                                \
    if (cp->namespace) {                                \
        Tcl_SetStringObj (rObj, cp->namespace, -1);     \
        Tcl_AppendToObj (rObj, ":", 1);                 \
    }                                                   \
    Tcl_AppendToObj (rObj, cp->name, -1);



static SchemaCP*
initSchemaCP (
    Schema_CP_Type type,
    void *namespace,
    char *name
    )
{
................................................................................
    FREE (sdata->evalStub);
    Tcl_DecrRefCount (sdata->textStub[0]);
    Tcl_DecrRefCount (sdata->textStub[1]);
    Tcl_DecrRefCount (sdata->textStub[2]);
    FREE (sdata->textStub);
    Tcl_DStringFree (sdata->cdata);
    FREE (sdata->cdata);



    FREE (sdata);
}

static void
cleanupLastPattern (
    SchemaData *sdata,
    unsigned int from
................................................................................
    )
{
    Tcl_Obj *cmdPtr;
    int rc;

    if (!sdata->reportCmd) return 0;
    cmdPtr = Tcl_DuplicateObj (sdata->reportCmd);

    Tcl_ListObjAppendElement (interp, cmdPtr,
                              sdata->self);
    Tcl_ListObjAppendElement (
        interp, cmdPtr,
        Tcl_NewStringObj (errType, len)
        );
    sdata->currentEvals++;
................................................................................
        while (ac < cp->nc) {
            candidate = cp->content[ac];
            mayskip = 0;
            switch (candidate->type) {
            case SCHEMA_CTYPE_TEXT:
                if (candidate->nc) {
                    if (!checkText (interp, candidate, "")) {
                        if (sdata->reportCmd) {
                            Tcl_Obj *cmdPtr;
                            cmdPtr = Tcl_DuplicateObj (sdata->reportCmd);
                            Tcl_ListObjAppendElement (interp, cmdPtr,
                                                      sdata->self);
                            fprintf (stderr, "HIER: %s\n",
                                     Tcl_GetString (sdata->self));
                            Tcl_ListObjAppendElement (
                                interp, cmdPtr,
                                Tcl_NewStringObj ("MISSING_TEXT", 12)
                                );
                            sdata->currentEvals++;
                            rc = Tcl_EvalObjEx (interp, cmdPtr,
                                                TCL_EVAL_GLOBAL
                                                | TCL_EVAL_DIRECT);
                            sdata->currentEvals--;
                            Tcl_DecrRefCount (cmdPtr);
                            if (rc != TCL_OK) {
                                return 0;
                            }
                            break;
                        }                        
                        return 0;
                    }
                }
                break;

................................................................................
                    return 1;
                }
                popStack (sdata);

                break;
            }
            if (!mayskip && mustMatch (cp->quants[ac], hm)) {






                return 0;
            }
            ac++;
            hm = 0;
        }
        if (isName) {
            if (recover (interp, sdata, "MISSING_ELEMENT", 15)) {
                /* Skip the just opened element tag and the following
                 * content of it. */
                sdata->skipDeep = 2;
                return 1;
            }
            return 0;
        }
        return -1;

    case SCHEMA_CTYPE_VIRTUAL:






>
>







 







>
>
>







 







>







 







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







 







>
>
>
>
>
>






|


|







251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
...
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
...
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
...
802
803
804
805
806
807
808
809



















810
811
812
813
814
815
816
...
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
    rObj = Tcl_NewObj();                                \
    if (cp->namespace) {                                \
        Tcl_SetStringObj (rObj, cp->namespace, -1);     \
        Tcl_AppendToObj (rObj, ":", 1);                 \
    }                                                   \
    Tcl_AppendToObj (rObj, cp->name, -1);

#define S(str)  str, sizeof (str) -1

static SchemaCP*
initSchemaCP (
    Schema_CP_Type type,
    void *namespace,
    char *name
    )
{
................................................................................
    FREE (sdata->evalStub);
    Tcl_DecrRefCount (sdata->textStub[0]);
    Tcl_DecrRefCount (sdata->textStub[1]);
    Tcl_DecrRefCount (sdata->textStub[2]);
    FREE (sdata->textStub);
    Tcl_DStringFree (sdata->cdata);
    FREE (sdata->cdata);
    if (sdata->reportCmd) {
        Tcl_DecrRefCount (sdata->reportCmd);
    }
    FREE (sdata);
}

static void
cleanupLastPattern (
    SchemaData *sdata,
    unsigned int from
................................................................................
    )
{
    Tcl_Obj *cmdPtr;
    int rc;

    if (!sdata->reportCmd) return 0;
    cmdPtr = Tcl_DuplicateObj (sdata->reportCmd);
    Tcl_IncrRefCount(cmdPtr);
    Tcl_ListObjAppendElement (interp, cmdPtr,
                              sdata->self);
    Tcl_ListObjAppendElement (
        interp, cmdPtr,
        Tcl_NewStringObj (errType, len)
        );
    sdata->currentEvals++;
................................................................................
        while (ac < cp->nc) {
            candidate = cp->content[ac];
            mayskip = 0;
            switch (candidate->type) {
            case SCHEMA_CTYPE_TEXT:
                if (candidate->nc) {
                    if (!checkText (interp, candidate, "")) {
                        if (recover (interp, sdata, S("MISSING_TEXT"))) {



















                            break;
                        }                        
                        return 0;
                    }
                }
                break;

................................................................................
                    return 1;
                }
                popStack (sdata);

                break;
            }
            if (!mayskip && mustMatch (cp->quants[ac], hm)) {
                if (recover (interp, sdata, S("MISSING_CP"))) {
                    /* Skip the just opened element tag and the following
                     * content of the current. */
                    sdata->skipDeep = 2;
                    return 1;
                }
                return 0;
            }
            ac++;
            hm = 0;
        }
        if (isName) {
            if (recover (interp, sdata, "UNEXPECTED_ELEMENT", 15)) {
                /* Skip the just opened element tag and the following
                 * content of it. */
                sdata->skipDeep = 1;
                return 1;
            }
            return 0;
        }
        return -1;

    case SCHEMA_CTYPE_VIRTUAL:

Changes to tests/schema.test.

3776
3777
3778
3779
3780
3781
3782

3783
3784
3785
3786
3787
3788
3789







3790











        defelement doc {
            element e
            text {minLength 1}
            element e
        }
    }
    s reportcmd schema-18

    set rc [s validate {<doc><e/></doc>} errMsg]
    puts $errMsg
    lappend result $rc
    s delete
    set result
} {MISSING_TEXT s 1}








}

















>







>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
        defelement doc {
            element e
            text {minLength 1}
            element e
        }
    }
    s reportcmd schema-18
    set result ""
    set rc [s validate {<doc><e/></doc>} errMsg]
    puts $errMsg
    lappend result $rc
    s delete
    set result
} {MISSING_TEXT s 1}

test schema-18.2 {reportcmd} {
    tdom::schema s
    s define {
        defelement doc {
            element a
            element b
            element c
        }
    }
    s reportcmd schema-18
    set result ""
    set rc [s validate {<doc><a/><c/></doc>} errMsg]
    puts $errMsg
    lappend result $rc
    s delete
    set result
} {s MISSING_CP 1}

}