Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Still working on digest local key constraint specification: Now support union "Path ( '|' Path )*" for selector and fields. Distinct between element and attribute selecting steps because of the distict spaces of the names. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | localkey |
Files: | files | file ages | folders |
SHA3-256: |
69c262ef77b5d563a14710a291deae7d |
User & Date: | rolf 2019-05-16 22:25:02.816 |
Original Comment: | still working on digest local key constraint specification: Now support union "Path ( '|' Path )*" for selector and fields. Distinct between element and attribute selecting steps because of the distict spaces of the the names. |
Context
2019-05-17
| ||
00:02 | Now start to actually use the local key constraint info. check-in: 120c8294a0 user: rolf tags: localkey | |
2019-05-16
| ||
22:25 | Still working on digest local key constraint specification: Now support union "Path ( '|' Path )*" for selector and fields. Distinct between element and attribute selecting steps because of the distict spaces of the names. check-in: 69c262ef77 user: rolf tags: localkey | |
2019-05-15
| ||
00:16 | Enhanced the unique schema contraint: the fields argument is now expected to be a proper tcl list with their elements as the field XPath expressions. check-in: abc0715900 user: rolf tags: localkey | |
Changes
Changes to generic/schema.c.
︙ | ︙ | |||
374 375 376 377 378 379 380 | /* DBG end */ static void freeKeyConstraints ( KeyConstraint *kc ) { KeyConstraint *knext; | | | > > > | > > > > > | > > | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | /* DBG end */ static void freeKeyConstraints ( KeyConstraint *kc ) { KeyConstraint *knext; KeyStep *step, *snext, *child, *nchild; int i; while (kc) { knext = kc->next; if (kc->name) FREE (kc->name); step = kc->selector; while (step) { snext = step->next; child = step; while (child) { nchild = child->child; FREE (child); child = nchild; } step = snext; } for (i = 0; i < kc->nrFields; i++) { step = kc->fields[i]; while (step) { snext = step->next; child = step; while (child) { nchild = child->child; FREE (child); child = nchild; } step = snext; } } FREE (kc->fields); FREE (kc); kc = knext; } |
︙ | ︙ | |||
3451 3452 3453 3454 3455 3456 3457 | extern void printAst (int depth, ast t); static int processSchemaXPath ( Tcl_Interp *interp, SchemaData *sdata, KeyConstraint *kc, | < | > | | | | > > > > > | > > > > > > > > | < > > > | > > > > > > > > > > > > > > > > > > > > | > | | | > | > > > > > > > > | > > | | | > > > > > | | | | > > > | | | > > > > > > > | | < > < < < | > > > | > > > > | | | 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 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 3534 3535 3536 3537 3538 3539 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 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 | extern void printAst (int depth, ast t); static int processSchemaXPath ( Tcl_Interp *interp, SchemaData *sdata, KeyConstraint *kc, StepType nextType, ast t, int field, int toplevel ) { ast child, savedt; KeyStep *step, *curstep; Tcl_HashTable *table; Tcl_HashEntry *h; int rc, hnew; SchemaCP *cp; /* if (toplevel) printAst (0, t); */ while (t) { switch (t->type) { case GetContextNode: if (!toplevel) { SetResult ("Not a reduced XPath expression."); return 0; } t = t->next; continue; case CombineSets: child = t->child; if (child->type == EvalSteps) { savedt = NULL; child = child->child; } else { savedt = child->next; child->next = NULL; } if (field) { step = kc->fields[field-1]; kc->fields[field-1] = NULL; } else { step = kc->selector; kc->selector = NULL; } if (!processSchemaXPath (interp, sdata, kc, SCHEMA_STEP_NONE, child, field, toplevel)) { if (savedt) child->next = savedt; if (field) kc->fields[field-1] = step; else kc->selector = step; return 0; } if (step) { if (field) { curstep = step; while (curstep->next) curstep = curstep->next; curstep->next = kc->fields[field-1]; } else { curstep = step; while (curstep->next) curstep = curstep->next; step->next = kc->selector; } } else { if (field) { step = kc->fields[field-1]; } else { step = kc->selector; } } if (field) kc->fields[field-1] = NULL; else kc->selector = NULL; if (savedt) child->next = savedt; child = t->child->next; if (child->type == EvalSteps) child = child->child; rc = processSchemaXPath (interp, sdata, kc, SCHEMA_STEP_NONE, child, field, toplevel); if (field) { if (kc->fields[field-1]) { curstep = step; while (curstep->next) curstep = curstep->next; curstep->next = kc->fields[field-1]; } kc->fields[field-1] = step; } else { if (kc->selector) { curstep = step; while (curstep->next) curstep = curstep->next; curstep->next = kc->selector; } kc->selector = step; } return rc; case AxisDescendant: if (!toplevel) { SetResult ("Not a reduced XPath expression."); return 0; } nextType = SCHEMA_STEP_DESCENDANT_ELEMENT; break; case IsNSAttr: case IsAttr: if (!field) { SetResult ("Attribute selection is only possible in reduced " "XPath expression for field selectors."); return 0; } /* Fall through */ case IsElement: case IsFQElement: case IsNSElement: savedt = t; step = TMALLOC (KeyStep); memset (step, 0, sizeof (KeyStep)); step->type = nextType; if (t->type == IsAttr || t->type == IsNSAttr) { table = &sdata->attrNames; } else { table = &sdata->element; } if (t->type == IsFQElement || t->type == IsNSAttr) { h = Tcl_CreateHashEntry (&sdata->namespace, t->strvalue, &hnew); step->ns = Tcl_GetHashKey (&sdata->namespace, h); t = t->child; } h = Tcl_CreateHashEntry (table, t->strvalue, &hnew); if (hnew && (table == &sdata->element)) { cp = initSchemaCP (SCHEMA_CTYPE_NAME, step->ns, Tcl_GetHashKey (&sdata->element, h)); cp->flags |= PLACEHOLDER_PATTERN_DEF; REMEMBER_PATTERN (cp); Tcl_SetHashValue (h, cp); } step->name = Tcl_GetHashKey (table, h); if (field) { if (kc->fields[field-1]) { curstep = kc->fields[field-1]; while (curstep->child) curstep = curstep->child; curstep->child = step; } else { kc->fields[field-1] = step; } } else { if (kc->selector) { curstep = kc->selector; while (curstep->child) curstep = curstep->child; curstep->child = step; } else { kc->selector = step; } } t = savedt; break; case AxisAttribute: if (!field) { SetResult ("Attribute selection is only possible in reduced " "XPath expression for field selectors."); return 0; } /* Fall through */ case AxisChild: if (t->type == AxisChild) nextType = SCHEMA_STEP_ELEMENT; else nextType = SCHEMA_STEP_ATTRIBUTE; if (!processSchemaXPath (interp, sdata, kc, nextType, t->child, field, 0)) { return 0; } break; default: SetResult ("Not a reduced XPath expression."); return 0; } toplevel = 0; t = t->next; } return 1; } static int uniquePatternCmd ( ClientData clientData, Tcl_Interp *interp, int objc, |
︙ | ︙ | |||
3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 | } if (Tcl_ListObjLength (interp, objv[2], &nrFields) != TCL_OK) { SetResult ("The <fieldlist> argument must be a valid tcl list"); xpathFreeAst (t); return TCL_ERROR; } kc = TMALLOC (KeyConstraint); memset (kc, 0, sizeof (KeyConstraint)); kc->fields = MALLOC (sizeof (KeyStep*) * nrFields); | > > > > > > > | | | | | | 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 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 | } if (Tcl_ListObjLength (interp, objv[2], &nrFields) != TCL_OK) { SetResult ("The <fieldlist> argument must be a valid tcl list"); xpathFreeAst (t); return TCL_ERROR; } if (nrFields == 0) { SetResult ("Non empty fieldlist arugment expected."); xpathFreeAst (t); return TCL_ERROR; } kc = TMALLOC (KeyConstraint); memset (kc, 0, sizeof (KeyConstraint)); kc->fields = MALLOC (sizeof (KeyStep*) * nrFields); memset (kc->fields, 0, sizeof (KeyStep*) * nrFields); kc->nrFields = nrFields; if (!processSchemaXPath (interp, sdata, kc, SCHEMA_STEP_NONE, t, 0, 1)) { xpathFreeAst (t); freeKeyConstraints (kc); return TCL_ERROR; } xpathFreeAst (t); for (i = 0; i < nrFields; i++) { Tcl_ListObjIndex (interp, objv[2], i, &elm); if (xpathParse (Tcl_GetString (elm), NULL, XPATH_EXPR, sdata->prefixns, NULL, &t, &errMsg) < 0) { SetResult3 ("Error in field xpath: '", errMsg, ""); FREE (errMsg); xpathFreeAst (t); freeKeyConstraints (kc); return TCL_ERROR; } if (!processSchemaXPath (interp, sdata, kc, SCHEMA_STEP_NONE, t, i+1, 1)) { xpathFreeAst (t); freeKeyConstraints (kc); return TCL_ERROR; } xpathFreeAst (t); } if (objc == 4) { |
︙ | ︙ |
Changes to generic/schema.h.
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 97 98 99 100 | typedef struct KeyStep { StepType type; char *name; char *ns; struct KeyStep *next; } KeyStep; typedef struct KeyConstraint { char *name; KeyType type; KeyStep *selector; | > | | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | typedef struct KeyStep { StepType type; char *name; char *ns; struct KeyStep *next; struct KeyStep *child; } KeyStep; typedef struct KeyConstraint { char *name; KeyType type; KeyStep *selector; KeyStep **fields; int nrFields; struct KeyConstraint *next; } KeyConstraint; typedef struct SchemaCP { Schema_CP_Type type; |
︙ | ︙ |
Changes to tests/schema.test.
︙ | ︙ | |||
4683 4684 4685 4686 4687 4688 4689 | } { tdom::schema s lappend result [catch {s define $schema} errMsg] #puts $errMsg s delete } set result | > | > > > > > > > > > > > > > > > > > | 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 | } { tdom::schema s lappend result [catch {s define $schema} errMsg] #puts $errMsg s delete } set result } {0 1 1 0 0 0 1 0 0 1 1 0 1 1 0 1 1 1 1} test schema-19.2a {unique} { set schema { prefixns {ns1 http://tdom.org/test} defelement doc { unique ${::schema-19.2} {{@ref | div/@id} @lang} } } set result [list] foreach ::schema-19.2 { {e/b | a/b | e/f } } { tdom::schema s lappend result [catch {s define $schema}] s delete } set result } 0 test schema-19.3 {unique} { tdom::schema s s define { defelement doc { unique item @lang element item * { |
︙ | ︙ |