Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | INVALID_DOM_KEYCONSTRAINT is really not a validation error but a validation script error (as a TCL_ERROR from a called script. Though, the evalError flag isn't respected anywhere, obviously. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | wip |
Files: | files | file ages | folders |
SHA3-256: |
a77a3f3b2360b82163ebbc72328b34aa |
User & Date: | rolf 2019-10-25 00:30:16 |
Context
2019-10-26
| ||
01:20 | Fixed not always poping up of tcl errors in called script during validation. check-in: a43c523416 user: rolf tags: wip | |
2019-10-25
| ||
00:30 | INVALID_DOM_KEYCONSTRAINT is really not a validation error but a validation script error (as a TCL_ERROR from a called script. Though, the evalError flag isn't respected anywhere, obviously. check-in: a77a3f3b23 user: rolf tags: wip | |
2019-10-24
| ||
22:05 | Merged from trunk. check-in: c416325b0b user: rolf tags: wip | |
Changes
Changes to generic/schema.c.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 .. 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 ... 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 .... 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 .... 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 .... 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 .... 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 .... 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 .... 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 |
int onlyWhiteSpace; char *uri; int maxUriLen; } ValidateMethodData; typedef enum { DOM_KEYCONSTRAINT, INVALID_DOM_KEYCONSTRAINT, MISSING_ANY, MISSING_ATTRIBUTE, MISSING_CP, MISSING_ELEMENT, MISSING_ONE_OF_CHOICE, MISSING_ONE_OF_INTERLEAVE, MISSING_TEXT, ................................................................................ UNKOWN_ID, INVALID_ATTRIBUTE_VALUE, INVALID_VALUE } ValidationErrorType; static char *ValidationErrorType2str[] = { "DOM_KEYCONSTRAINT", "INVALID_DOM_KEYCONSTRAINT", "MISSING_ANY", "MISSING_ATTRIBUTE", "MISSING_CP", "MISSING_ELEMENT", "MISSING_ONE_OF_CHOICE", "MISSING_ONE_OF_INTERLEAVE", "MISSING_TEXT", ................................................................................ Tcl_DecrRefCount (cmdPtr); if (rc != TCL_OK) { sdata->evalError = 1; return 0; } switch (errorType) { case DOM_KEYCONSTRAINT: case INVALID_DOM_KEYCONSTRAINT: case MISSING_ANY: case MISSING_ATTRIBUTE: case MISSING_CP: case MISSING_ELEMENT: case MISSING_ONE_OF_CHOICE: case MISSING_ONE_OF_INTERLEAVE: case MISSING_TEXT: ................................................................................ ) { Tcl_HashEntry *h, *h1; Tcl_HashSearch search, search1; int haveErrMsg = 0; SchemaDocKey *dk; /* TODO: add recovering */ if (sdata->evalError) return 0; if (sdata->unknownIDrefs) { if (!recover (interp, sdata, S("UNKOWN_ID"), 0, 0)) { haveErrMsg = 1; SetResult ("References to unknown IDs:"); for (h = Tcl_FirstHashEntry (&sdata->ids, &search); h != NULL; ................................................................................ Tcl_DStringInit (&dStr); while (kc) { xpathRSReset (&rs, NULL); xpathRSReset (&nodeList, node); Tcl_InitHashTable (&htable, TCL_STRING_KEYS); rc = xpathEvalAst (kc->selector, &nodeList, node, &rs, &errMsg); if (rc) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { goto nextConstraint; } goto errorCleanup; } if (rs.type == EmptyResult) goto nextConstraint; if (rs.type != xNodeSetResult) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { goto nextConstraint; } SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } for (i = 0; i < rs.nr_nodes; i++) { n = rs.nodes[i]; if (n->nodeType != ELEMENT_NODE) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { break; } SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } xpathRSReset (&nodeList, n); if (kc->nrFields == 1) { xpathRSReset (&frs, NULL); rc = xpathEvalAst (kc->fields[0], &nodeList, n, &frs, &errMsg); if (rc) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { break; } SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.type != xNodeSetResult && frs.type != EmptyResult) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { break; } SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.type == EmptyResult || frs.nr_nodes == 0) { if (kc->flags & DKC_FLAG_IGNORE_EMPTY_FIELD_SET) { continue; } ................................................................................ break; } SetResult ("DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.nodes[0]->nodeType != ELEMENT_NODE && frs.nodes[0]->nodeType != ATTRIBUTE_NODE) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { break; } SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.nodes[0]->nodeType == ATTRIBUTE_NODE) { attr = (domAttrNode *) frs.nodes[0]; Tcl_CreateHashEntry (&htable, attr->nodeValue, &hnew); if (!hnew) { ................................................................................ skip = 0; first = 1; for (j = 0; j < kc->nrFields; j++) { xpathRSReset (&frs, NULL); rc = xpathEvalAst (kc->fields[j], &nodeList, n, &frs, &errMsg); if (rc) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { skip = 1; break; } SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.type != xNodeSetResult && frs.type != EmptyResult) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { skip = 1; break; } SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.type == EmptyResult || frs.nr_nodes == 0) { if (kc->flags & DKC_FLAG_IGNORE_EMPTY_FIELD_SET) { continue; } ................................................................................ break; } SetResult ("DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.nodes[0]->nodeType != ELEMENT_NODE && frs.nodes[0]->nodeType != ATTRIBUTE_NODE) { if (recover (interp, sdata, S("INVALID_DOM_KEYCONSTRAINT"), 0, 0)) { skip = 1; break; } SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (first) first = 0; else Tcl_DStringAppend (&dStr, ":", 1); if (frs.nodes[0]->nodeType == ATTRIBUTE_NODE) { attr = (domAttrNode *) frs.nodes[0]; ................................................................................ Tcl_WrongNumArgs (interp, 1, objv, "definedElements"); return TCL_ERROR; } definedElements (sdata, interp); break; case m_stack: if (Tcl_GetIndexFromObj (interp, objv[2], schemaInstanceInfoStackMethods, "method", 0, &methodIndex) != TCL_OK) { return TCL_ERROR; } switch ((enum schemaInstanceInfoStackMethod) methodIndex) { case m_top: break; case m_inside: if (!sdata->stack) { Tcl_ResetResult (interp); return TCL_OK; } se = sdata->stack; while (se->pattern->type != SCHEMA_CTYPE_NAME) { se = se->down; |
< < < < | < < < < < < < < | < < < < | | < < < < < < < < < < < | < < < < < < < < > > > > | | > > > > > > > > > > > > > > > > | |
76 77 78 79 80 81 82 83 84 85 86 87 88 89 .. 97 98 99 100 101 102 103 104 105 106 107 108 109 110 ... 960 961 962 963 964 965 966 967 968 969 970 971 972 973 .... 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 .... 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 .... 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 .... 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 .... 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 .... 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 |
int onlyWhiteSpace; char *uri; int maxUriLen; } ValidateMethodData; typedef enum { DOM_KEYCONSTRAINT, MISSING_ANY, MISSING_ATTRIBUTE, MISSING_CP, MISSING_ELEMENT, MISSING_ONE_OF_CHOICE, MISSING_ONE_OF_INTERLEAVE, MISSING_TEXT, ................................................................................ UNKOWN_ID, INVALID_ATTRIBUTE_VALUE, INVALID_VALUE } ValidationErrorType; static char *ValidationErrorType2str[] = { "DOM_KEYCONSTRAINT", "MISSING_ANY", "MISSING_ATTRIBUTE", "MISSING_CP", "MISSING_ELEMENT", "MISSING_ONE_OF_CHOICE", "MISSING_ONE_OF_INTERLEAVE", "MISSING_TEXT", ................................................................................ Tcl_DecrRefCount (cmdPtr); if (rc != TCL_OK) { sdata->evalError = 1; return 0; } switch (errorType) { case DOM_KEYCONSTRAINT: case MISSING_ANY: case MISSING_ATTRIBUTE: case MISSING_CP: case MISSING_ELEMENT: case MISSING_ONE_OF_CHOICE: case MISSING_ONE_OF_INTERLEAVE: case MISSING_TEXT: ................................................................................ ) { Tcl_HashEntry *h, *h1; Tcl_HashSearch search, search1; int haveErrMsg = 0; SchemaDocKey *dk; if (sdata->evalError) return 0; if (sdata->unknownIDrefs) { if (!recover (interp, sdata, S("UNKOWN_ID"), 0, 0)) { haveErrMsg = 1; SetResult ("References to unknown IDs:"); for (h = Tcl_FirstHashEntry (&sdata->ids, &search); h != NULL; ................................................................................ Tcl_DStringInit (&dStr); while (kc) { xpathRSReset (&rs, NULL); xpathRSReset (&nodeList, node); Tcl_InitHashTable (&htable, TCL_STRING_KEYS); rc = xpathEvalAst (kc->selector, &nodeList, node, &rs, &errMsg); if (rc) { SetResult (errMsg); goto errorCleanup; } if (rs.type == EmptyResult) goto nextConstraint; if (rs.type != xNodeSetResult) { SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } for (i = 0; i < rs.nr_nodes; i++) { n = rs.nodes[i]; if (n->nodeType != ELEMENT_NODE) { SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } xpathRSReset (&nodeList, n); if (kc->nrFields == 1) { xpathRSReset (&frs, NULL); rc = xpathEvalAst (kc->fields[0], &nodeList, n, &frs, &errMsg); if (rc) { SetResult (errMsg); goto errorCleanup; } if (frs.type != xNodeSetResult && frs.type != EmptyResult) { SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.type == EmptyResult || frs.nr_nodes == 0) { if (kc->flags & DKC_FLAG_IGNORE_EMPTY_FIELD_SET) { continue; } ................................................................................ break; } SetResult ("DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.nodes[0]->nodeType != ELEMENT_NODE && frs.nodes[0]->nodeType != ATTRIBUTE_NODE) { SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.nodes[0]->nodeType == ATTRIBUTE_NODE) { attr = (domAttrNode *) frs.nodes[0]; Tcl_CreateHashEntry (&htable, attr->nodeValue, &hnew); if (!hnew) { ................................................................................ skip = 0; first = 1; for (j = 0; j < kc->nrFields; j++) { xpathRSReset (&frs, NULL); rc = xpathEvalAst (kc->fields[j], &nodeList, n, &frs, &errMsg); if (rc) { SetResult (errMsg); goto errorCleanup; } if (frs.type != xNodeSetResult && frs.type != EmptyResult) { SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.type == EmptyResult || frs.nr_nodes == 0) { if (kc->flags & DKC_FLAG_IGNORE_EMPTY_FIELD_SET) { continue; } ................................................................................ break; } SetResult ("DOM_KEYCONSTRAINT"); goto errorCleanup; } if (frs.nodes[0]->nodeType != ELEMENT_NODE && frs.nodes[0]->nodeType != ATTRIBUTE_NODE) { SetResult ("INVALID_DOM_KEYCONSTRAINT"); goto errorCleanup; } if (first) first = 0; else Tcl_DStringAppend (&dStr, ":", 1); if (frs.nodes[0]->nodeType == ATTRIBUTE_NODE) { attr = (domAttrNode *) frs.nodes[0]; ................................................................................ Tcl_WrongNumArgs (interp, 1, objv, "definedElements"); return TCL_ERROR; } definedElements (sdata, interp); break; case m_stack: if (objc != 3) { Tcl_WrongNumArgs (interp, 2, objv, "top|inside"); return TCL_ERROR; } if (Tcl_GetIndexFromObj (interp, objv[3], schemaInstanceInfoStackMethods, "method", 0, &methodIndex) != TCL_OK) { return TCL_ERROR; } switch ((enum schemaInstanceInfoStackMethod) methodIndex) { case m_inside: if (!sdata->stack) { Tcl_ResetResult (interp); return TCL_OK; } se = sdata->stack; rObj = Tcl_NewObj(); while (se) { if (se->pattern->type == SCHEMA_CTYPE_NAME) { Tcl_ListObjAppendElement (interp, rObj, serializeElementName (interp, se->pattern)); } se = se->down; } Tcl_SetObjResult (interp, rObj); return TCL_OK; break; case m_top: if (!sdata->stack) { Tcl_ResetResult (interp); return TCL_OK; } se = sdata->stack; while (se->pattern->type != SCHEMA_CTYPE_NAME) { se = se->down; |
Changes to tests/schema.test.
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
....
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
|
set result [s validate {<doc><a><b>foo</b><c/></a><a><b></b><c>bar</c></a></doc>} msg] s delete lappend result $msg ${schema-15.2} set result } {1 {} astartaendastartaend} proc schema-15.3 {type cmd} { lappend ::schema-15.3 $type [$cmd info stack inside] } test schema-15.3 {constraint cmd tcl} { tdom::schema s s define { defelement doc { element a * ................................................................................ s event start doc catch {s event start unknownElement} s delete } set result } {a b c d} proc schema-18 {args} { lappend ::result {*}$args } test schema-18.1 {reportcmd} { tdom::schema s s define { defelement doc { |
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
....
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
|
set result [s validate {<doc><a><b>foo</b><c/></a><a><b></b><c>bar</c></a></doc>} msg] s delete lappend result $msg ${schema-15.2} set result } {1 {} astartaendastartaend} proc schema-15.3 {type cmd} { lappend ::schema-15.3 $type [$cmd info stack top] } test schema-15.3 {constraint cmd tcl} { tdom::schema s s define { defelement doc { element a * ................................................................................ s event start doc catch {s event start unknownElement} s delete } set result } {a b c d} proc schema-17.15 {type cmd} { lappend ::result $type [$cmd info stack ] } test schema-17.15 {info inside} { tdom::schema s s define { defelement doc { element a * } defelement a { tcl schema-17.15 astart element b ! text element c ! text tcl schema-17.15 aend } } set result {} s validate {<doc><a><b>foo</b><c/></a><a><b></b><c>bar</c></a></doc>} s delete set result } {1 {} astart {a doc} aend a astart a aend a} proc schema-18 {args} { lappend ::result {*}$args } test schema-18.1 {reportcmd} { tdom::schema s s define { defelement doc { |