tDOM

Check-in [f3cb326ad5]
Login

Check-in [f3cb326ad5]

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

Overview
Comment:Added subcommand definedElementtypes to the schema command method info, returning the list of all defined element types.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: f3cb326ad5d5ee7488317aac97bbecc4f345826175b22dbd7ecaf55bc9883e88
User & Date: rolf 2020-01-05 01:14:07.043
Context
2020-01-10
23:26
Pacified a (bogus) compiler warning. check-in: 21822aeab7 user: rolf tags: schema
2020-01-05
01:14
Added subcommand definedElementtypes to the schema command method info, returning the list of all defined element types. check-in: f3cb326ad5 user: rolf tags: schema
00:15
Added schema command subcommand method info typedefinition to query defelementtype definition details. check-in: 81cd49d4ec user: rolf tags: schema
Changes
Unified Diff Ignore Whitespace Patch
Changes to generic/schema.c.
3254
3255
3256
3257
3258
3259
3260

















3261
3262
3263
3264
3265
3266
3267
    Tcl_ListObjAppendElement (interp, rObj, Tcl_NewStringObj (cp->name, -1));
    if (cp->namespace) {
        Tcl_ListObjAppendElement (interp, rObj,
                                  Tcl_NewStringObj (cp->namespace, -1));
    }
    return rObj;
}


















/* cp must be of type SCHEMA_CTYPE_ANY for useful results */
static Tcl_Obj*
serializeAnyCP (
    Tcl_Interp *interp,
    SchemaCP *cp
    )







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







3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
    Tcl_ListObjAppendElement (interp, rObj, Tcl_NewStringObj (cp->name, -1));
    if (cp->namespace) {
        Tcl_ListObjAppendElement (interp, rObj,
                                  Tcl_NewStringObj (cp->namespace, -1));
    }
    return rObj;
}

static Tcl_Obj*
serializeElementTypeName (
    Tcl_Interp *interp,
    SchemaCP *cp
    )
{
    Tcl_Obj *rObj;

    rObj = Tcl_NewObj();
    Tcl_ListObjAppendElement (interp, rObj, Tcl_NewStringObj (cp->typeName, -1));
    if (cp->namespace) {
        Tcl_ListObjAppendElement (interp, rObj,
                                  Tcl_NewStringObj (cp->namespace, -1));
    }
    return rObj;
}

/* cp must be of type SCHEMA_CTYPE_ANY for useful results */
static Tcl_Obj*
serializeAnyCP (
    Tcl_Interp *interp,
    SchemaCP *cp
    )
3328
3329
3330
3331
3332
3333
3334
























3335
3336
3337
3338
3339
3340
3341
        if (!cp) continue;
        if (cp->flags & FORWARD_PATTERN_DEF
            || cp->flags & PLACEHOLDER_PATTERN_DEF) continue;
        elmObj = serializeElementName (interp, cp);
        Tcl_ListObjAppendElement (interp, rObj, elmObj);
    }
}

























static int
getNextExpectedWorker (
    SchemaData *sdata,
    SchemaValidationStack *se,
    Tcl_Interp *interp,
    Tcl_HashTable *seenCPs,







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







3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
        if (!cp) continue;
        if (cp->flags & FORWARD_PATTERN_DEF
            || cp->flags & PLACEHOLDER_PATTERN_DEF) continue;
        elmObj = serializeElementName (interp, cp);
        Tcl_ListObjAppendElement (interp, rObj, elmObj);
    }
}

static void
definedElementtypes (
    SchemaData *sdata,
    Tcl_Interp *interp
    )
{
    Tcl_Obj *rObj, *elmObj;
    Tcl_HashEntry *h;
    Tcl_HashSearch search;
    SchemaCP *cp;
    
    rObj = Tcl_GetObjResult (interp);
    for (h = Tcl_FirstHashEntry (&sdata->elementType, &search);
         h != NULL;
         h = Tcl_NextHashEntry (&search)) {
        cp = (SchemaCP *) Tcl_GetHashValue (h);
        if (!cp) continue;
        if (cp->flags & FORWARD_PATTERN_DEF
            || cp->flags & PLACEHOLDER_PATTERN_DEF) continue;
        elmObj = serializeElementTypeName (interp, cp);
        Tcl_ListObjAppendElement (interp, rObj, elmObj);
    }
}

static int
getNextExpectedWorker (
    SchemaData *sdata,
    SchemaValidationStack *se,
    Tcl_Interp *interp,
    Tcl_HashTable *seenCPs,
3581
3582
3583
3584
3585
3586
3587
3588

3589
3590
3591
3592
3593

3594
3595
3596
3597
3598
3599
3600
    SchemaValidationStack *se;
    void *ns;
    Tcl_Obj *rObj;
    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "definedElements", "stack", "toplevel",
        "expected", "definition", "validationaction", "vaction", "line",
        "column", "domNode", "nrForwardDefinitions", "typedefinition", 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, m_typedefinition

    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside







|
>




|
>







3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
    SchemaValidationStack *se;
    void *ns;
    Tcl_Obj *rObj;
    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "definedElements", "stack", "toplevel",
        "expected", "definition", "validationaction", "vaction", "line",
        "column", "domNode", "nrForwardDefinitions", "typedefinition",
        "definedElementtypes", 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, m_typedefinition,
        m_definedElementtypes
    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside
3641
3642
3643
3644
3645
3646
3647








3648
3649
3650
3651
3652
3653
3654
    case m_definedElements:
        if (objc != 2) {
            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[2],







>
>
>
>
>
>
>
>







3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
    case m_definedElements:
        if (objc != 2) {
            Tcl_WrongNumArgs (interp, 1, objv, "definedElements");
            return TCL_ERROR;
        }
        definedElements (sdata, interp);
        break;

    case m_definedElementtypes:
        if (objc != 2) {
            Tcl_WrongNumArgs (interp, 1, objv, "definedElementtypes");
            return TCL_ERROR;
        }
        definedElementtypes (sdata, interp);
        break;

    case m_stack:
        if (objc != 3) {
            Tcl_WrongNumArgs (interp, 2, objv, "top|inside");
            return TCL_ERROR;
        }
        if (Tcl_GetIndexFromObj (interp, objv[2],
Changes to tests/schema.test.
7183
7184
7185
7186
7187
7188
7189


















7190
7191
7192
7193
7194
7195
7196
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 1 0 0}



















test schema-23.1 {validatefile} {
    tdom::schema s
    s define {
        set fd [open [file join [file dir [info script]] ../doc/tmml.schema] r]
        eval [read $fd]
        close $fd
    }







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







7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 0 0 1 0 0}

test schema-22.6 {defelementtype} {
    tdom::schema s
    s prefixns {ns http://my.foo}
    s defelement doc ns {
        elementtype a
        elementtype a2
    }
    s defelementtype a a ns {
        elementtype e1
    }
    s defelementtype a2 a ns {
        elementtype e2
    }
    set result [lsort -index 0 [s info definedElementtypes]]
    s delete
    set result
} {{a http://my.foo} {a2 http://my.foo}}

test schema-23.1 {validatefile} {
    tdom::schema s
    s define {
        set fd [open [file join [file dir [info script]] ../doc/tmml.schema] r]
        eval [read $fd]
        close $fd
    }