tDOM

Check-in [d70281b9c7]
Login
Bounty program for improvements to Tcl and certain Tcl packages.

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

Overview
Comment:Save work.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip
Files: files | file ages | folders
SHA3-256: d70281b9c74d5e48cc9ebfbf7380b810c347417273103384b21e67e67a865651
User & Date: rolf 2020-03-16 00:38:13
Context
2020-03-19
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
2020-03-15
01:20
wip check-in: 899c21f84b user: rolf tags: wip
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

1020
1021
1022
1023
1024
1025
1026
1027







1028
1029
1030
1031
1032
1033
1034
}

static void
rewindStack (
    SchemaData *sdata
    ) 
{
    return;







}

static int 
recover (
    Tcl_Interp *interp,
    SchemaData *sdata,
    ValidationErrorType errorType,






|
>
>
>
>
>
>
>







1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
}

static void
rewindStack (
    SchemaData *sdata
    ) 
{
    SchemaValidationStack *se;

    while (sdata->lastMatchse) {
        se = sdata->lastMatchse;
        sdata->lastMatchse = se->down;
        se->down = sdata->stack;
        sdata->stack = se;
    }
}

static int 
recover (
    Tcl_Interp *interp,
    SchemaData *sdata,
    ValidationErrorType errorType,

Changes to tests/schema.test.

7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
....
7751
7752
7753
7754
7755
7756
7757

7758











7759
7760
7761
7762
7763
7764
7765
....
7769
7770
7771
7772
7773
7774
7775





























7776
7777
7778
7779
7780
7781
7782
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {}

test schema-18.18 {missing element} {
    set defs {
        {
            defelement doc {
                ref r1
            }
            defpattern r1 {
                element a ! {}
................................................................................
            defelement doc {
                element a 1 {}
                element b 1 {}
            }
        }
        {
            defelement doc {

                ref r1











            }
            defpattern r1 {
                element a ! {}
                element b ! {}
            }
        }
    }
................................................................................
        s reportcmd appendtoresult
        s define $def
        lappend result [s validate {<doc/>}]
        s delete
    }
    set result
} {}






























proc validatedSAX {g xml {keepEmpties 1}} {
    set args [list -validateCmd $g]
    if {!$keepEmpties} {
        lappend args -ignorewhitespace 1
    }
    xml::parser p {*}$args






|







 







>

>
>
>
>
>
>
>
>
>
>
>







 







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







7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
....
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
....
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
    } {
        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 a ! {}
................................................................................
            defelement doc {
                element a 1 {}
                element b 1 {}
            }
        }
        {
            defelement doc {
                element a0 ! {}
                ref r1
            }
            defpattern r1 {
                element a ! {}
                element b ! {}
            }
        }
        {
            defelement doc {
                element a0 ! {}
                ref r1
                element b0 ! {}
            }
            defpattern r1 {
                element a ! {}
                element b ! {}
            }
        }
    }
................................................................................
        s reportcmd appendtoresult
        s define $def
        lappend result [s validate {<doc/>}]
        s delete
    }
    set result
} {}

test schema-18.19 {unexpected text} {
    tdom::schema s
    s reportcmd appendtoresult
    s define {
        defelement doc {
            ref r1 ?
            element c ? {}
        }
        defpattern r1 {
            element a ? {}
            element b ? {}
        }
    }
    set result [list]
    foreach xml {
        <doc>unexpected_text<c/></doc>
        <doc>unexpected_text<a/><c/></doc>
        <doc><a/>unexpected_text<c/></doc>
        <doc><a/>unexpected_text<b/><c/></doc>
        <doc><a/><b/>unexpected_text<c/></doc>
        <doc><a/><b/><c/>unexpected_text</doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {UNEXPECTED_TEXT 1 UNEXPECTED_TEXT 1 UNEXPECTED_TEXT 1 UNEXPECTED_TEXT 1 UNEXPECTED_TEXT 1 UNEXPECTED_TEXT 1}


proc validatedSAX {g xml {keepEmpties 1}} {
    set args [list -validateCmd $g]
    if {!$keepEmpties} {
        lappend args -ignorewhitespace 1
    }
    xml::parser p {*}$args