tDOM

Check-in [c24f9bedb3]
Login

Check-in [c24f9bedb3]

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

Overview
Comment:Fixed bug in case of missing required attributes w/ reportCmd.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: c24f9bedb36e8a5c4882166c748597ef4be4b2d511f487659cbfca69db8ebd8b
User & Date: rolf 2020-03-14 02:45:27.146
Context
2020-03-14
02:48
Gardening. check-in: 74cd3204f1 user: rolf tags: schema
02:45
Fixed bug in case of missing required attributes w/ reportCmd. check-in: c24f9bedb3 user: rolf tags: schema
2020-03-10
22:38
Fixed seg fault in error handling of invalid domunique usage. check-in: f552cf0e3e user: rolf tags: schema
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/schema.c.
3188
3189
3190
3191
3192
3193
3194
3195
3196



3197

3198

3199
3200
3201
3202
3203
3204
3205
    if (sdata->skipDeep == 0) {
        if (node->firstAttr) {
            if (probeDomAttributes (interp, sdata, node->firstAttr) != TCL_OK) {
                return TCL_ERROR;
            }
        } else {
            if (sdata->stack->pattern->numReqAttr) {
                /* probeDomAttributes fills interp result with a msg which
                 * required attributes are missing. */



                probeDomAttributes (interp, sdata, NULL);

                return TCL_ERROR;

            }
        }
    }

    if (sdata->stack->pattern->domKeys) {
        if (checkdomKeyConstraints (interp, sdata, node) != TCL_OK)
            return TCL_ERROR;







|
|
>
>
>
|
>
|
>







3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
    if (sdata->skipDeep == 0) {
        if (node->firstAttr) {
            if (probeDomAttributes (interp, sdata, node->firstAttr) != TCL_OK) {
                return TCL_ERROR;
            }
        } else {
            if (sdata->stack->pattern->numReqAttr) {
                /* probeDomAttributes fills interp result with a msg
                 * which required attributes are missing in case of no
                 * reportCmd. In case of reportCmd
                 * probeDomAttributes() returns only error in the case
                 * of error in called scripts. */
                if (probeDomAttributes (interp, sdata, NULL) != TCL_OK) {
                    /* fprintf (stderr, "HIER\n"); */
                    return TCL_ERROR;
                }
            }
        }
    }

    if (sdata->stack->pattern->domKeys) {
        if (checkdomKeyConstraints (interp, sdata, node) != TCL_OK)
            return TCL_ERROR;
Changes to tests/schema.test.
3501
3502
3503
3504
3505
3506
3507



















3508
3509
3510
3511
3512
3513
3514
        {<doc xmlns:ns1="http://foo.bar" xmlns:ns2="http://foo.grill" xmlns:ns3="http://bar.grill"><e abc="" optional="this" ns3:optional="that" def="" ghi="" jkl="" mno="" pqr="" ns2:abc="" ns1:abc="" ns3:abc=""/></doc>}
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {MISSING_ATTRIBUTE abc {} 1 1 MISSING_ATTRIBUTE abc http://foo.bar 1 UNKNOWN_ATTRIBUTE abc http://bar.grill 1 MISSING_ATTRIBUTE abc {} 1 1 UNKNOWN_ATTRIBUTE abc http://bar.grill 1}




















test schema-12.1 {domvalidate} {
    tdom::schema s 
    s define {
        defelement addressBook {
            element card *
        }







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







3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
        {<doc xmlns:ns1="http://foo.bar" xmlns:ns2="http://foo.grill" xmlns:ns3="http://bar.grill"><e abc="" optional="this" ns3:optional="that" def="" ghi="" jkl="" mno="" pqr="" ns2:abc="" ns1:abc="" ns3:abc=""/></doc>}
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {MISSING_ATTRIBUTE abc {} 1 1 MISSING_ATTRIBUTE abc http://foo.bar 1 UNKNOWN_ATTRIBUTE abc http://bar.grill 1 MISSING_ATTRIBUTE abc {} 1 1 UNKNOWN_ATTRIBUTE abc http://bar.grill 1}

proc schema-11.11 {scmd errType} {
    lappend ::result $errType
}
test schema-11.11 {attribute - required missing} {
    tdom::schema s
    s defelement doc {
        element a + {
            attribute mode
        }
    }
    s reportcmd schema-11.11
    set result ""
    set doc [dom parse <doc><a/></doc>]
    lappend result [s domvalidate $doc]
    $doc delete
    s delete
    set result
} {MISSING_ATTRIBUTE 1}

test schema-12.1 {domvalidate} {
    tdom::schema s 
    s define {
        defelement addressBook {
            element card *
        }