Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Started work. (Wenn es anders nicht geht, so geht es doch viel besser.) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | keyspaces |
Files: | files | file ages | folders |
SHA3-256: |
11c1cd9dad3fef4487d831a4ea0a5666 |
User & Date: | rolf 2019-05-25 00:46:11.456 |
Context
2019-05-25
| ||
12:32 | Added the new CTYPE also to the debug functions. check-in: 9049114cc3 user: rolf tags: keyspaces | |
00:46 | Started work. (Wenn es anders nicht geht, so geht es doch viel besser.) check-in: 11c1cd9dad user: rolf tags: keyspaces | |
2019-05-21
| ||
22:30 | Added dom tree validation specific unique key contraints along the lines of xsd unqiue with selector and list of fields but with no restrictions on the XPath expressions (other then resulting a node set in case of selector and a result set with one node in case of field XPath expression). check-in: ba6bd2bb7c user: rolf tags: schema | |
Changes
Changes to generic/schema.c.
︙ | ︙ | |||
296 297 298 299 300 301 302 303 304 305 306 307 308 309 | break; case SCHEMA_CTYPE_TEXT: /* content/quant will be allocated, if the cp in fact has * constraints */ break; case SCHEMA_CTYPE_VIRTUAL: case SCHEMA_CTYPE_ANY: /* Do nothing */ break; } return pattern; } DDBG( | > | 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | break; case SCHEMA_CTYPE_TEXT: /* content/quant will be allocated, if the cp in fact has * constraints */ break; case SCHEMA_CTYPE_VIRTUAL: case SCHEMA_CTYPE_ANY: case SCHEMA_CTYPE_KEYSPACE: /* Do nothing */ break; } return pattern; } DDBG( |
︙ | ︙ | |||
923 924 925 926 927 928 929 930 931 932 933 934 935 936 | popStack (sdata); if (rc == -1) mayskip = 1; break; case SCHEMA_CTYPE_VIRTUAL: Tcl_Panic ("Virtual constrain in MIXED or CHOICE"); } if (!mayskip && mayMiss (candidate->quants[i])) mayskip = 1; } break; case SCHEMA_CTYPE_VIRTUAL: | > > > | 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 | popStack (sdata); if (rc == -1) mayskip = 1; break; case SCHEMA_CTYPE_VIRTUAL: Tcl_Panic ("Virtual constrain in MIXED or CHOICE"); case SCHEMA_CTYPE_KEYSPACE: Tcl_Panic ("Keyspace constrain in MIXED or CHOICE"); } if (!mayskip && mayMiss (candidate->quants[i])) mayskip = 1; } break; case SCHEMA_CTYPE_VIRTUAL: |
︙ | ︙ | |||
951 952 953 954 955 956 957 958 959 960 961 962 963 964 | rc = matchElementStart (interp, sdata, name, namespace); if (rc == 1) { updateStack (se, cp, ac); return 1; } popStack (sdata); break; } if (!mayskip && mustMatch (cp->quants[ac], hm)) { if (recover (interp, sdata, S("MISSING_CP"))) { /* Skip the just opened element tag and the following * content of the current. */ sdata->skipDeep = 2; | > > > | 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 | rc = matchElementStart (interp, sdata, name, namespace); if (rc == 1) { updateStack (se, cp, ac); return 1; } popStack (sdata); break; case SCHEMA_CTYPE_KEYSPACE: break; } if (!mayskip && mustMatch (cp->quants[ac], hm)) { if (recover (interp, sdata, S("MISSING_CP"))) { /* Skip the just opened element tag and the following * content of the current. */ sdata->skipDeep = 2; |
︙ | ︙ | |||
976 977 978 979 980 981 982 983 984 985 986 987 988 989 | sdata->skipDeep = 2; return 1; } return 0; } return -1; case SCHEMA_CTYPE_VIRTUAL: case SCHEMA_CTYPE_CHOICE: case SCHEMA_CTYPE_TEXT: case SCHEMA_CTYPE_ANY: /* Never pushed onto stack */ Tcl_Panic ("Invalid CTYPE onto the validation stack!"); | > | 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | sdata->skipDeep = 2; return 1; } return 0; } return -1; case SCHEMA_CTYPE_KEYSPACE: case SCHEMA_CTYPE_VIRTUAL: case SCHEMA_CTYPE_CHOICE: case SCHEMA_CTYPE_TEXT: case SCHEMA_CTYPE_ANY: /* Never pushed onto stack */ Tcl_Panic ("Invalid CTYPE onto the validation stack!"); |
︙ | ︙ | |||
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 | popStack (sdata); if (mayskip && rc != -1) mayskip = 0; break; case SCHEMA_CTYPE_VIRTUAL: Tcl_Panic ("Virtual constraint child of INTERLEAVE"); break; } } if (mayskip) break; if (recover (interp, sdata, S("UNCOMPLET_CP"))) { sdata->skipDeep = 2; | > > > > > | 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 | popStack (sdata); if (mayskip && rc != -1) mayskip = 0; break; case SCHEMA_CTYPE_VIRTUAL: Tcl_Panic ("Virtual constraint child of INTERLEAVE"); break; case SCHEMA_CTYPE_KEYSPACE: Tcl_Panic ("Keyspace constraint child of INTERLEAVE"); break; } } if (mayskip) break; if (recover (interp, sdata, S("UNCOMPLET_CP"))) { sdata->skipDeep = 2; |
︙ | ︙ | |||
1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 | DBG(fprintf (stderr, "ac %d hm %d mayMiss: %d\n", ac, hm, mayMiss (cp->quants[ac]))); if (mayMiss (cp->quants[ac])) { ac++; continue; } switch (cp->content[ac]->type) { case SCHEMA_CTYPE_TEXT: if (cp->content[ac]->nc) { if (!checkText (interp, cp->content[ac], "")) { if (recover (interp, sdata, S("MISSING_TEXT"))) { break; } return 0; | > > > | 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 | DBG(fprintf (stderr, "ac %d hm %d mayMiss: %d\n", ac, hm, mayMiss (cp->quants[ac]))); if (mayMiss (cp->quants[ac])) { ac++; continue; } switch (cp->content[ac]->type) { case SCHEMA_CTYPE_KEYSPACE: break; case SCHEMA_CTYPE_TEXT: if (cp->content[ac]->nc) { if (!checkText (interp, cp->content[ac], "")) { if (recover (interp, sdata, S("MISSING_TEXT"))) { break; } return 0; |
︙ | ︙ | |||
1494 1495 1496 1497 1498 1499 1500 | if (!checkText (interp, ic, "")) { continue; } } mayMiss = 1; break; | < < > > | | 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 | if (!checkText (interp, ic, "")) { continue; } } mayMiss = 1; break; case SCHEMA_CTYPE_NAME: case SCHEMA_CTYPE_ANY: continue; case SCHEMA_CTYPE_INTERLEAVE: case SCHEMA_CTYPE_PATTERN: pushToStack (sdata, ic); if (checkElementEnd (interp, sdata)) { mayMiss = 1; } popStack (sdata); break; case SCHEMA_CTYPE_KEYSPACE: case SCHEMA_CTYPE_VIRTUAL: case SCHEMA_CTYPE_CHOICE: Tcl_Panic ("Invalid CTYPE in MIXED or CHOICE"); } if (mayMiss) break; } if (mayMiss) break; if (!recover (interp, sdata, S("MISSING_ONE_OF_CHOICE"))) { return 0; |
︙ | ︙ | |||
1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 | return 0; } ac++; } if (isName) return 1; return -1; case SCHEMA_CTYPE_VIRTUAL: case SCHEMA_CTYPE_CHOICE: case SCHEMA_CTYPE_TEXT: case SCHEMA_CTYPE_ANY: /* Never pushed onto stack */ Tcl_Panic ("Invalid CTYPE onto the validation stack!"); return 0; | > | 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | return 0; } ac++; } if (isName) return 1; return -1; case SCHEMA_CTYPE_KEYSPACE: case SCHEMA_CTYPE_VIRTUAL: case SCHEMA_CTYPE_CHOICE: case SCHEMA_CTYPE_TEXT: case SCHEMA_CTYPE_ANY: /* Never pushed onto stack */ Tcl_Panic ("Invalid CTYPE onto the validation stack!"); return 0; |
︙ | ︙ | |||
1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 | case SCHEMA_CTYPE_VIRTUAL: if (!evalVirtual (interp, sdata, ic)) return 0; break; case SCHEMA_CTYPE_CHOICE: Tcl_Panic ("MIXED or CHOICE child of MIXED or CHOICE"); } } if (mustMatch (cp->quants[ac], hm)) { SetResult ("Unexpected text content"); return 0; } break; | > > > | 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 | case SCHEMA_CTYPE_VIRTUAL: if (!evalVirtual (interp, sdata, ic)) return 0; break; case SCHEMA_CTYPE_CHOICE: Tcl_Panic ("MIXED or CHOICE child of MIXED or CHOICE"); case SCHEMA_CTYPE_KEYSPACE: Tcl_Panic ("Keyspace constrain in MIXED or CHOICE"); } } if (mustMatch (cp->quants[ac], hm)) { SetResult ("Unexpected text content"); return 0; } break; |
︙ | ︙ | |||
1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 | SetResult ("Unexpected text content"); return 0; } break; case SCHEMA_CTYPE_VIRTUAL: if (!evalVirtual (interp, sdata, candidate)) return 0; break; case SCHEMA_CTYPE_NAME: case SCHEMA_CTYPE_ANY: if (mustMatch (cp->quants[ac], hm)) { SetResult ("Unexpected text content"); return 0; | > > > > | 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 | SetResult ("Unexpected text content"); return 0; } break; case SCHEMA_CTYPE_VIRTUAL: if (!evalVirtual (interp, sdata, candidate)) return 0; break; case SCHEMA_CTYPE_KEYSPACE: break; case SCHEMA_CTYPE_NAME: case SCHEMA_CTYPE_ANY: if (mustMatch (cp->quants[ac], hm)) { SetResult ("Unexpected text content"); return 0; |
︙ | ︙ | |||
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 | } popStack (sdata); break; case SCHEMA_CTYPE_CHOICE: Tcl_Panic ("MIXED or CHOICE child of INTERLEAVE"); case SCHEMA_CTYPE_VIRTUAL: break; } } } break; } return 0; } int | > > > > > > > | 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 | } popStack (sdata); break; case SCHEMA_CTYPE_CHOICE: Tcl_Panic ("MIXED or CHOICE child of INTERLEAVE"); case SCHEMA_CTYPE_KEYSPACE: Tcl_Panic ("Keyspace child of INTERLEAVE"); case SCHEMA_CTYPE_VIRTUAL: break; } } case SCHEMA_CTYPE_KEYSPACE: break; } break; } return 0; } int |
︙ | ︙ | |||
3642 3643 3644 3645 3646 3647 3648 | CHECK_SI CHECK_TOPLEVEL if (objc < 2) { SetResult ("Expected: <tclcmd> ?arg? ?arg? ..."); return TCL_ERROR; } | < | | < < | 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 | CHECK_SI CHECK_TOPLEVEL if (objc < 2) { SetResult ("Expected: <tclcmd> ?arg? ?arg? ..."); return TCL_ERROR; } if (sdata->cp->type != SCHEMA_CTYPE_NAME && sdata->cp->type != SCHEMA_CTYPE_PATTERN) { SetResult ("The \"tcl\" schema definition command is only " "allowed in sequential context (defelement, " "element or defpattern)"); return TCL_ERROR; } pattern = initSchemaCP (SCHEMA_CTYPE_VIRTUAL, NULL, NULL); |
︙ | ︙ | |||
3668 3669 3670 3671 3672 3673 3674 | } pattern->nc = objc; addToContent (sdata, pattern, SCHEMA_CQUANT_ONE, 0, 0); return TCL_OK; } static int | | | 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 | } pattern->nc = objc; addToContent (sdata, pattern, SCHEMA_CQUANT_ONE, 0, 0); return TCL_OK; } static int domuniquePatternObjCmd ( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[] ) { SchemaData *sdata = GETASI; |
︙ | ︙ | |||
3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 | kc->fields[i] = t; } if (objc == 4) { kc->name = tdomstrdup (Tcl_GetString (objv[3])); } kc->next = sdata->cp->domKeys; sdata->cp->domKeys = kc; return TCL_OK; } static int integerImpl ( Tcl_Interp *interp, void *constraintData, | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 | kc->fields[i] = t; } if (objc == 4) { kc->name = tdomstrdup (Tcl_GetString (objv[3])); } kc->next = sdata->cp->domKeys; sdata->cp->domKeys = kc; return TCL_OK; } static int keyspacePatternObjCmd ( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[] ) { SchemaData *sdata = GETASI; SchemaCP *pattern; int nrFlags; CHECK_SI CHECK_TOPLEVEL checkNrArgs (2, 3, "Expected: <keyspace-name> ?flags?"); if (sdata->cp->type != SCHEMA_CTYPE_NAME && sdata->cp->type != SCHEMA_CTYPE_PATTERN) { SetResult ("The keyspace schema definition command is only " "allowed in sequential context (defelement, " "element or defpattern)"); return TCL_ERROR; } if (objc == 3) { if (Tcl_ListObjLength (interp, objv[2], &nrFlags) != TCL_OK) { SetResult ("The optional <flags> argument must be a valid tcl " "list"); return TCL_ERROR; } } pattern = initSchemaCP (SCHEMA_CTYPE_KEYSPACE, NULL, NULL); REMEMBER_PATTERN (pattern); return TCL_OK; } static int integerImpl ( Tcl_Interp *interp, void *constraintData, |
︙ | ︙ | |||
5038 5039 5040 5041 5042 5043 5044 | Tcl_CreateObjCommand (interp, "tdom::schema::mixed", AnonPatternObjCmd, (ClientData) 1, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::interleave", AnonPatternObjCmd, (ClientData) 2, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::group", AnonPatternObjCmd, (ClientData) 3, NULL); | | > > > > > | | 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 | Tcl_CreateObjCommand (interp, "tdom::schema::mixed", AnonPatternObjCmd, (ClientData) 1, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::interleave", AnonPatternObjCmd, (ClientData) 2, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::group", AnonPatternObjCmd, (ClientData) 3, NULL); /* The "attribute", "nsattribute", "namespace" and "text" * definition commands. */ Tcl_CreateObjCommand (interp, "tdom::schema::attribute", AttributePatternObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::nsattribute", AttributePatternObjCmd, (ClientData) 1, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::namespace", NamespacePatternObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::text", TextPatternObjCmd, NULL, NULL); /* The 'virtual' "tcl" definition command */ Tcl_CreateObjCommand (interp, "tdom::schema::tcl", VirtualPatternObjCmd, NULL, NULL); /* XPath contraints for DOM validation */ Tcl_CreateObjCommand (interp,"tdom::schema::domunique", domuniquePatternObjCmd, NULL, NULL); /* Local key constraints */ Tcl_CreateObjCommand (interp, "tdom::schema::keyspace", keyspacePatternObjCmd, NULL, NULL); /* The text constraint commands */ Tcl_CreateObjCommand (interp,"tdom::schema::text::integer", integerTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::text::tcl", tclTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp, "tdom::schema::text::fixed", |
︙ | ︙ |
Changes to generic/schema.h.
︙ | ︙ | |||
30 31 32 33 34 35 36 | typedef enum { SCHEMA_CTYPE_ANY, SCHEMA_CTYPE_NAME, SCHEMA_CTYPE_CHOICE, SCHEMA_CTYPE_INTERLEAVE, SCHEMA_CTYPE_PATTERN, SCHEMA_CTYPE_TEXT, | | > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | typedef enum { SCHEMA_CTYPE_ANY, SCHEMA_CTYPE_NAME, SCHEMA_CTYPE_CHOICE, SCHEMA_CTYPE_INTERLEAVE, SCHEMA_CTYPE_PATTERN, SCHEMA_CTYPE_TEXT, SCHEMA_CTYPE_VIRTUAL, SCHEMA_CTYPE_KEYSPACE } Schema_CP_Type; typedef enum { SCHEMA_CQUANT_ONE, SCHEMA_CQUANT_OPT, SCHEMA_CQUANT_REP, SCHEMA_CQUANT_PLUS, |
︙ | ︙ |