tDOM

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

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

Overview
Comment:Fixed the damn thing.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip2
Files: files | file ages | folders
SHA3-256: 8fb5a0b988d8ed382842dddd05766868a7ae1e495649ba730c7b60d5cf94d89c
User & Date: rolf 2020-03-14 03:24:21
Context
2020-03-14
03:25
Added flag -ignorematched to the schema commant submethod info expected. check-in: 0dc7c2f6cc user: rolf tags: schema
03:24
Fixed the damn thing. Closed-Leaf check-in: 8fb5a0b988 user: rolf tags: wip2
02:49
Merged from schema. check-in: 4582355609 user: rolf tags: wip2
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

3517
3518
3519
3520
3521
3522
3523

3524
3525
3526
3527
3528
3529
3530
....
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908

3909
3910
3911
3912
3913
3914
3915
    int ac, hm, i, hnew, mustMatch, mayskip, rc = 1;
    SchemaCP *cp, *ic, *jc;
    SchemaValidationStack *se1;

    getContext (cp, ac, hm);
    if (ignoreMatched && hm) {
        ac++;

    } else {
        if (hm && maxOne(cp->quants[ac])) ac++;
    }
    switch (cp->type) {
    case SCHEMA_CTYPE_INTERLEAVE:
        ac = 0;
        mustMatch = 0;
................................................................................

    case m_expected:
        if (objc != 2 && objc != 3) {
            Tcl_WrongNumArgs (interp, 2, objv, "?-ignorematched?");
            return TCL_ERROR;
        }
        ignoreMatched = 0;
        if (objc == 3
            && strcmp (Tcl_GetString (objv[2]), "-ignorematched") != 0) {
            SetResult ("Expected -ignorematched");
            return TCL_ERROR;

            ignoreMatched = 1;
        }
        
        if (sdata->validationState == VALIDATION_ERROR
            || sdata->validationState == VALIDATION_FINISHED) {
            return TCL_OK;
        }






>







 







|
|
|
|
>







3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
....
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
    int ac, hm, i, hnew, mustMatch, mayskip, rc = 1;
    SchemaCP *cp, *ic, *jc;
    SchemaValidationStack *se1;

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

    case m_expected:
        if (objc != 2 && objc != 3) {
            Tcl_WrongNumArgs (interp, 2, objv, "?-ignorematched?");
            return TCL_ERROR;
        }
        ignoreMatched = 0;
        if (objc == 3) {
            if (strcmp (Tcl_GetString (objv[2]), "-ignorematched") != 0) {
                SetResult ("Expected -ignorematched");
                return TCL_ERROR;
            }
            ignoreMatched = 1;
        }
        
        if (sdata->validationState == VALIDATION_ERROR
            || sdata->validationState == VALIDATION_FINISHED) {
            return TCL_OK;
        }

Changes to tests/schema.test.

6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
....
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
....
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
....
7233
7234
7235
7236
7237
7238
7239
































7240
7241
7242
7243
7244
7245
7246
        s event start doc
        s event start b
        s event end
        set result [lsort [s info expected -ignorematched]]
        s delete
    }
    set result
} {a b c d}

test schema-17.12 {info expected} {
    tdom::schema s
    s define {
        prefixns {ns1 http://foo.bar}
        defelement doc {
            element a
................................................................................
    } {
        set fromReportCmd ""
        lappend result [s validate $xml]
        lappend result {*}$fromReportCmd
    }
    s delete
    set result
} {0 0 1 1 aaaa b bb bbb bbbb 1 aaaa b bb bbb bbbb 1}

test schema-17.16a_1 {info expected} {
    tdom::schema s
    s defelement doc {
        element a
        group {
            group {
................................................................................
    } {
        set fromReportCmd ""
        lappend result [s validate $xml]
        lappend result {*}$fromReportCmd
    }
    s delete
    set result
} {0 0 1 1 aaaa b bb bbb bbbb 1 aaaa b bb bbb bbbb 1}

test schema-17.16b {info expected} {
    tdom::schema s
    s defelement doc {
        element a
        group {
            group {
................................................................................
        <doc><a/><b/></doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {{} 1 1 1 {fo bar baz} 1 {} 1}

































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






|







 







|







 







|







 







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







6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
....
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
....
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
....
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
        s event start doc
        s event start b
        s event end
        set result [lsort [s info expected -ignorematched]]
        s delete
    }
    set result
} {d}

test schema-17.12 {info expected} {
    tdom::schema s
    s define {
        prefixns {ns1 http://foo.bar}
        defelement doc {
            element a
................................................................................
    } {
        set fromReportCmd ""
        lappend result [s validate $xml]
        lappend result {*}$fromReportCmd
    }
    s delete
    set result
} {0 0 1 1 aaaa b bb bbb bbbb 1 b bb bbb bbbb 1}

test schema-17.16a_1 {info expected} {
    tdom::schema s
    s defelement doc {
        element a
        group {
            group {
................................................................................
    } {
        set fromReportCmd ""
        lappend result [s validate $xml]
        lappend result {*}$fromReportCmd
    }
    s delete
    set result
} {0 0 1 1 aaaa b bb bbb bbbb 1 b bb bbb bbbb 1}

test schema-17.16b {info expected} {
    tdom::schema s
    s defelement doc {
        element a
        group {
            group {
................................................................................
        <doc><a/><b/></doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {{} 1 1 1 {fo bar baz} 1 {} 1}

proc schema-17.21 {scmd errorInfo} {
    lappend ::result [$scmd info expected]
}
test schema-17.21 {info expected} {
    tdom::schema s
    s defelement doc {
        element a + {}
        element b ! {}
    }
    s reportcmd schema-17.21
    set result ""
    lappend result [s validate {<doc><a/><unexpected/></doc>}]
    s delete
    set result
} {{a b} 1}

proc schema-17.21a {scmd errorInfo} {
    lappend ::result [$scmd info expected -ignorematched]
}
test schema-17.21a {info expected} {
    tdom::schema s
    s defelement doc {
        element a + {}
        element b ! {}
    }
    s reportcmd schema-17.21a
    set result ""
    lappend result [s validate {<doc><a/><unexpected/></doc>}]
    s delete
    set result
} {b 1}

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