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

Overview
Comment:Started check for ambiguity.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | wip
Files: files | file ages | folders
SHA3-256: a2f83dea7e81b7e18c2de602258bd776c82e6ff243975f62632d9689e679baea
User & Date: rolf 2019-11-15 23:46:44
Context
2019-11-15
23:46
Started check for ambiguity. Leaf check-in: a2f83dea7e user: rolf tags: wip
15:17
Updated documentation example section. check-in: c0721894cc user: rolf tags: schema
Changes

Changes to generic/schema.c.

3372
3373
3374
3375
3376
3377
3378



























































3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390

3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
....
3540
3541
3542
3543
3544
3545
3546


3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559

3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
....
3635
3636
3637
3638
3639
3640
3641





























3642
3643
3644
3645
3646
3647
3648
            break;
        }
    }
    Tcl_DeleteHashTable (&localHash);
    Tcl_SetObjResult (interp, unifyMatchList (interp, &localHash, rObj));
    Tcl_DecrRefCount (rObj);
}




























































static int
schemaInstanceInfoCmd (
    SchemaData *sdata,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[]
    )
{
    int methodIndex;
    long line, column;
    Tcl_HashEntry *h;

    SchemaCP *cp;
    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
................................................................................
        break;
        
    case m_definition:
        if (objc < 3 && objc > 4) {
            Tcl_WrongNumArgs (interp, 1, objv, "name ?namespace?");
            return TCL_ERROR;
        }


        h = Tcl_FindHashEntry (&sdata->element, Tcl_GetString (objv[2]));
        if (!h) {
            SetResult ("Unknown element definition");
            return TCL_ERROR;
        }
        cp = Tcl_GetHashValue (h);
        ns = NULL;
        if (objc == 4) {
            ns = getNamespacePtr (sdata, Tcl_GetString (objv[3]));
        }
        while (cp && cp->namespace != ns) {
            cp = cp->next;
        }

        if (!cp
            || cp->flags & LOCAL_DEFINED_ELEMENT
            || cp->flags & PLACEHOLDER_PATTERN_DEF) {
            SetResult ("Unknown element definition");
            return TCL_ERROR;
        }
        Tcl_AppendElement (interp, "defelement");
        Tcl_AppendElement (interp, cp->name);
        if (cp->namespace) {
            Tcl_AppendElement (interp, cp->namespace);
................................................................................
        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







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












>


<





|




|







 







>
>
|
<
<
<
<
<
<
<
|
<
<
<
<
>
|
<
<







 







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







3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452

3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
....
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608







3609




3610
3611


3612
3613
3614
3615
3616
3617
3618
....
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
            break;
        }
    }
    Tcl_DeleteHashTable (&localHash);
    Tcl_SetObjResult (interp, unifyMatchList (interp, &localHash, rObj));
    Tcl_DecrRefCount (rObj);
}

static SchemaCP *
getDefinedElement (
    SchemaData *sdata,
    char *name,
    char *namespace
    ) 
{
    Tcl_HashEntry *h;
    SchemaCP *cp;
    char *ns = NULL;
    
    h = Tcl_FindHashEntry (&sdata->element, name);
    if (!h) {
        return NULL;
    }
    cp = Tcl_GetHashValue (h);
    if (namespace) {
        ns = getNamespacePtr (sdata, namespace);
    }
    while (cp && cp->namespace != ns) {
        cp = cp->next;
    }
    if (!cp
        || cp->flags & LOCAL_DEFINED_ELEMENT
        || cp->flags & PLACEHOLDER_PATTERN_DEF) {
        return NULL;
    }
    return cp;
}

static int
isambiguous (
    SchemaCP *cp
    ) 
{
    int i;
    SchemaCP *ip;
    char *seenname = NULL, *seenns = NULL;

    for (i = 0; i < cp->nc; i++) {
        ip = cp->content[i];
        switch (ip->type) {
        case SCHEMA_CTYPE_NAME:
            break;
        case SCHEMA_CTYPE_PATTERN:
            break;
        case SCHEMA_CTYPE_ANY:
            break;
        case SCHEMA_CTYPE_TEXT:
            break;
        case SCHEMA_CTYPE_INTERLEAVE:
            break;
        default:
            continue;
        }
    }
    return 0;
}

static int
schemaInstanceInfoCmd (
    SchemaData *sdata,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[]
    )
{
    int methodIndex;
    long line, column;
    Tcl_HashEntry *h;
    Tcl_HashSearch search;
    SchemaCP *cp;
    SchemaValidationStack *se;

    Tcl_Obj *rObj;
    
    static const char *schemaInstanceInfoMethods[] = {
        "validationstate", "vstate", "definedElements", "stack", "toplevel",
        "expected", "definition", "validationaction", "vaction", "line",
        "column", "domNode", "nrForwardDefinitions", "ambiguous", 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_ambiguous
    };

    static const char *schemaInstanceInfoStackMethods[] = {
        "top", "inside", NULL
    };
    enum schemaInstanceInfoStackMethod {
        m_top, m_inside
................................................................................
        break;
        
    case m_definition:
        if (objc < 3 && objc > 4) {
            Tcl_WrongNumArgs (interp, 1, objv, "name ?namespace?");
            return TCL_ERROR;
        }
        cp = getDefinedElement (
            sdata,
            Tcl_GetString (objv[2]),







            objc == 4 ? Tcl_GetString (objv[3]) : NULL




            );
        if (!cp) {


            SetResult ("Unknown element definition");
            return TCL_ERROR;
        }
        Tcl_AppendElement (interp, "defelement");
        Tcl_AppendElement (interp, cp->name);
        if (cp->namespace) {
            Tcl_AppendElement (interp, cp->namespace);
................................................................................
        if (objc != 2) {
            Tcl_WrongNumArgs(interp, 2, objv, "");
            return TCL_ERROR;
        }
        SetIntResult(sdata->forwardPatternDefs);
        break;

    case m_ambiguous:
        checkNrArgs (2,4, "Expected: info ambiguous ?name ?namespace??");
        if (objc == 2) {
            for (h = Tcl_FirstHashEntry (&sdata->element, &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;
                if (isambiguous (cp)) {
                    SetBooleanResult(1);
                    return TCL_OK;
                }
            }
            SetBooleanResult(0);
        } else {
            cp = getDefinedElement (
                sdata,
                Tcl_GetString (objv[2]),
                objc == 4 ? Tcl_GetString (objv[3]) : NULL
                );
            if (!cp) {
                SetResult ("Unknown element definition");
                return TCL_ERROR;
            }
            SetBooleanResult (isambiguous (cp));
        }
        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