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

Overview
Comment:Moved schema command method nrForwardDefinitions as subcommand to info; it belongs more there.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: 05086c2182517d4f349a634a501dd8a4efacd20e0af54e1f4c26f61454bc9eb9
User & Date: rolf 2019-11-15 10:22:32
Context
2019-11-15
13:45
Work on the info method and the documentation for that method. check-in: e3fd3c93a9 user: rolf tags: schema
10:22
Moved schema command method nrForwardDefinitions as subcommand to info; it belongs more there. check-in: 05086c2182 user: rolf tags: schema
09:30
Prevent call of the recovery report command in case of probed optional not matching pattern. Added recovery in a so far not handled case. check-in: 1ceabd63a5 user: rolf tags: schema
Changes

Changes to generic/schema.c.

3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
....
3623
3624
3625
3626
3627
3628
3629









3630
3631
3632
3633
3634
3635
3636
....
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675

3676
3677
3678
3679
3680
3681
3682
3683
3684
....
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
    SchemaValidationStack *se;
    void *ns;
    Tcl_Obj *rObj;
    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "definedElements", "stack", "toplevel",
        "expected", "definition", "validationaction", "vaction", "line",
        "column", "domNode", NULL
    };
    enum schemaInstanceInfoMethod {
        m_validationstate, m_vstate, m_definedElements, m_stack, m_toplevel,
        m_expected, m_definition, m_validationaction, m_vaction, m_line,
        m_column, m_domNode
    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside
................................................................................
        if (domGetLineColumn(sdata->node, &line, &column) < 0) break;
        SetLongResult (column);
        break;

    case m_domNode:
        if (!sdata->node) break;
        return tcldom_setInterpAndReturnVar (interp, sdata->node, 0, NULL);









    }
    return TCL_OK;
}

/* This implements the script interface to the created schema commands.

   Since validation may call out to tcl scripts those scripts may
................................................................................
    void          *namespacePtr, *savedNamespacePtr;
    char          *xmlstr, *errMsg;
    domDocument   *doc;
    domNode       *node;
    Tcl_Obj       *attData;

    static const char *schemaInstanceMethods[] = {
        "defelement",  "defpattern",  "start", "event",     "delete",
        "nrForwardDefinitions",       "reset", "define",    "validate",
        "domvalidate", "deftext",     "info",  "reportcmd", "prefixns",
        NULL
    };
    enum schemaInstanceMethod {
        m_defelement,  m_defpattern, m_start, m_event,     m_delete,

        m_nrForwardDefinitions,      m_reset, m_define,    m_validate,
        m_domvalidate, m_deftext,    m_info,  m_reportcmd, m_prefixns
    };

    static const char *eventKeywords[] = {
        "start", "end", "text", NULL
    };

    enum eventKeyword
................................................................................
            return TCL_ERROR;
        }
        Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
        /* We return immediately here to avoid clashes with postponed
           sdata cleanup at the end of the function. */
        return TCL_OK;

    case m_nrForwardDefinitions:
        if (objc != 2) {
            Tcl_WrongNumArgs(interp, 2, objv, "");
            return TCL_ERROR;
        }
        SetIntResult(sdata->forwardPatternDefs);
        break;

    case m_reset:
        CHECK_EVAL
        schemaReset (sdata);
        break;

    case m_validate:
        CHECK_EVAL







|




|







 







>
>
>
>
>
>
>
>
>







 







|
|
|
<


|
>
|
<







 







<
<
<
<
<
<
<
<







3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
....
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
....
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680

3681
3682
3683
3684
3685

3686
3687
3688
3689
3690
3691
3692
....
3978
3979
3980
3981
3982
3983
3984








3985
3986
3987
3988
3989
3990
3991
    SchemaValidationStack *se;
    void *ns;
    Tcl_Obj *rObj;
    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "definedElements", "stack", "toplevel",
        "expected", "definition", "validationaction", "vaction", "line",
        "column", "domNode", "nrForwardDefinitions", NULL
    };
    enum schemaInstanceInfoMethod {
        m_validationstate, m_vstate, m_definedElements, m_stack, m_toplevel,
        m_expected, m_definition, m_validationaction, m_vaction, m_line,
        m_column, m_domNode, m_nrForwardDefinitions
    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside
................................................................................
        if (domGetLineColumn(sdata->node, &line, &column) < 0) break;
        SetLongResult (column);
        break;

    case m_domNode:
        if (!sdata->node) break;
        return tcldom_setInterpAndReturnVar (interp, sdata->node, 0, NULL);

    case m_nrForwardDefinitions:
        if (objc != 2) {
            Tcl_WrongNumArgs(interp, 2, objv, "");
            return TCL_ERROR;
        }
        SetIntResult(sdata->forwardPatternDefs);
        break;

    }
    return TCL_OK;
}

/* This implements the script interface to the created schema commands.

   Since validation may call out to tcl scripts those scripts may
................................................................................
    void          *namespacePtr, *savedNamespacePtr;
    char          *xmlstr, *errMsg;
    domDocument   *doc;
    domNode       *node;
    Tcl_Obj       *attData;

    static const char *schemaInstanceMethods[] = {
        "defelement", "defpattern", "start",    "event",       "delete",
        "reset",      "define",     "validate", "domvalidate", "deftext",
        "info",       "reportcmd",  "prefixns",  NULL

    };
    enum schemaInstanceMethod {
        m_defelement, m_defpattern, m_start,    m_event,       m_delete,
        m_reset,      m_define,     m_validate, m_domvalidate, m_deftext,
        m_info,       m_reportcmd,  m_prefixns

    };

    static const char *eventKeywords[] = {
        "start", "end", "text", NULL
    };

    enum eventKeyword
................................................................................
            return TCL_ERROR;
        }
        Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
        /* We return immediately here to avoid clashes with postponed
           sdata cleanup at the end of the function. */
        return TCL_OK;









    case m_reset:
        CHECK_EVAL
        schemaReset (sdata);
        break;

    case m_validate:
        CHECK_EVAL

Changes to tests/schema.test.

400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
...
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
...
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
} {s1 s2 1 0 0 1}

test schema-1.22 {nrForwardDefinitions} {
    tdom::schema create s
    set result [list]
    s define {
        defelement e {
            lappend ::result [s nrForwardDefinitions]
            element e1
            lappend ::result [s nrForwardDefinitions]
            element e1
            lappend ::result [s nrForwardDefinitions]
            element e2
            lappend ::result [s nrForwardDefinitions]
        }
        foreach e {e1 e2} {
            defelement $e {text}
            lappend ::result [s nrForwardDefinitions]
        }
    }
    s delete
    set result
} {0 1 1 2 1 0}

test schema-1.23 {prefixns} {
................................................................................
        ref thatPattern ?
    }
    grammar delete
} {}

test schema-2.2 {grammar definition: ref} {
    tdom::schema create grammar
    set result [grammar nrForwardDefinitions]
    grammar defelement doc {
        ref thisPattern
        ref thatPattern ?
    }
    lappend result [grammar nrForwardDefinitions]
    grammar delete
    set result
} {0 2}

test schema-2.3 {forward defined ref} {
    set defs {
        {
................................................................................
test schema-2.3a {forward defined ref} {
    tdom::schema s
    s defelement doc {
        ref some
        element a
    }
    set result [s validate <doc><a/></doc>]
    lappend result [s nrForwardDefinitions]
    s delete
    set result
} {1 2}

test schema-2.4 {forward definded element} {
    set defs {
        {







|

|

|

|



|







 







|




|







 







|







400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
...
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
...
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
} {s1 s2 1 0 0 1}

test schema-1.22 {nrForwardDefinitions} {
    tdom::schema create s
    set result [list]
    s define {
        defelement e {
            lappend ::result [s info nrForwardDefinitions]
            element e1
            lappend ::result [s info nrForwardDefinitions]
            element e1
            lappend ::result [s info nrForwardDefinitions]
            element e2
            lappend ::result [s info nrForwardDefinitions]
        }
        foreach e {e1 e2} {
            defelement $e {text}
            lappend ::result [s info nrForwardDefinitions]
        }
    }
    s delete
    set result
} {0 1 1 2 1 0}

test schema-1.23 {prefixns} {
................................................................................
        ref thatPattern ?
    }
    grammar delete
} {}

test schema-2.2 {grammar definition: ref} {
    tdom::schema create grammar
    set result [grammar info nrForwardDefinitions]
    grammar defelement doc {
        ref thisPattern
        ref thatPattern ?
    }
    lappend result [grammar info nrForwardDefinitions]
    grammar delete
    set result
} {0 2}

test schema-2.3 {forward defined ref} {
    set defs {
        {
................................................................................
test schema-2.3a {forward defined ref} {
    tdom::schema s
    s defelement doc {
        ref some
        element a
    }
    set result [s validate <doc><a/></doc>]
    lappend result [s info nrForwardDefinitions]
    s delete
    set result
} {1 2}

test schema-2.4 {forward definded element} {
    set defs {
        {