Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch deviation Excluding Merge-Ins
This is equivalent to a diff from 43e20be75b to 5aac7f85df
2019-10-06
| ||
23:40 | Save work. check-in: b26625af9b user: rolf tags: wip | |
2019-10-05
| ||
12:32 | wip Closed-Leaf check-in: 5aac7f85df user: rolf tags: deviation | |
00:16 | More minor doc tweaking. check-in: 43e20be75b user: rolf tags: wip | |
00:06 | Minor work on the documentation. check-in: a5c850a58e user: rolf tags: wip | |
Changes to generic/schema.c.
119 119 #if defined(DEBUG) || defined(DDEBUG) 120 120 static char *Schema_CP_Type2str[] = { 121 121 "ANY", 122 122 "NAME", 123 123 "CHOICE", 124 124 "INTERLEAVE", 125 125 "PATTERN", 126 - "TEXT" 126 + "TEXT", 127 127 "VIRTUAL", 128 128 "KEYSPACE_START", 129 129 "KEYSPACE_END" 130 130 }; 131 131 static char *Schema_Quant_Type2str[] = { 132 132 "ONE", 133 133 "OPT", 134 134 "REP", 135 135 "PLUS", 136 - "NM" 136 + "NM", 137 + "ERROR" 137 138 }; 138 139 #endif 139 140 140 141 141 142 #ifndef TCL_THREADS 142 143 static SchemaData *activeSchemaData = 0; 143 144 # define GETASI activeSchemaData ................................................................................ 961 962 Tcl_Interp *interp, 962 963 SchemaData *sdata, 963 964 char *name, 964 965 char *namespace 965 966 ) 966 967 { 967 968 SchemaCP *cp, *candidate, *icp; 968 - int hm, ac, i, mayskip, rc; 969 + int hm, ac, i, rc, missing; 969 970 int isName = 0; 970 971 SchemaValidationStack *se; 971 972 972 973 if (!sdata->stack) return 0; 973 974 se = sdata->stack; 974 975 getContext (cp, ac, hm); 975 976 ................................................................................ 976 977 switch (cp->type) { 977 978 case SCHEMA_CTYPE_NAME: 978 979 isName = 1; 979 980 /* fall through */ 980 981 case SCHEMA_CTYPE_PATTERN: 981 982 while (ac < cp->nc) { 982 983 candidate = cp->content[ac]; 983 - mayskip = 0; 984 984 switch (candidate->type) { 985 985 case SCHEMA_CTYPE_TEXT: 986 986 if (candidate->nc) { 987 987 if (!checkText (interp, candidate, "")) { 988 988 if (recover (interp, sdata, S("MISSING_TEXT"), 989 989 1, ac)) { 990 990 return 1; ................................................................................ 1047 1047 pushToStack (sdata, icp, ac); 1048 1048 rc = matchElementStart (interp, sdata, name, namespace); 1049 1049 if (rc == 1) { 1050 1050 updateStack (se, cp, ac); 1051 1051 return 1; 1052 1052 } 1053 1053 popStack (sdata); 1054 - if (rc == -1) mayskip = 1; 1055 1054 break; 1056 1055 1057 1056 case SCHEMA_CTYPE_VIRTUAL: 1058 1057 Tcl_Panic ("Virtual constrain in MIXED or CHOICE"); 1059 1058 1060 1059 case SCHEMA_CTYPE_KEYSPACE_END: 1061 1060 case SCHEMA_CTYPE_KEYSPACE: 1062 1061 Tcl_Panic ("Keyspace constrain in MIXED or CHOICE"); 1063 1062 1064 1063 } 1065 - if (!mayskip && mayMiss (candidate->quants[i])) 1066 - mayskip = 1; 1067 1064 } 1068 1065 break; 1069 1066 1070 1067 case SCHEMA_CTYPE_VIRTUAL: 1071 1068 if (evalVirtual (interp, sdata, ac)) { 1072 - /* Virtual contraints are always quant ONE, so 1073 - * that the virtual constraints are called while 1074 - * looking if an element can end. Therefor we use 1075 - * here the already present mayskip mechanism to 1076 - * try further, after calling the tcl script. */ 1077 - mayskip = 1; 1069 + hm = 1; 1078 1070 break; 1079 1071 } 1080 1072 else return 0; 1081 1073 1082 1074 case SCHEMA_CTYPE_INTERLEAVE: 1083 1075 case SCHEMA_CTYPE_PATTERN: 1084 1076 pushToStack (sdata, candidate, ac); ................................................................................ 1115 1107 } else { 1116 1108 candidate->keySpace->active++; 1117 1109 } 1118 1110 ac++; 1119 1111 hm = 0; 1120 1112 continue; 1121 1113 } 1122 - if (!mayskip && mustMatch (cp->quants[ac], hm)) { 1114 + if (mustMatch (cp->quants[ac], hm)) { 1123 1115 if (recover (interp, sdata, S("MISSING_CP"), 1, ac)) { 1124 1116 /* Skip the just opened element tag and the following 1125 1117 * content of the current. */ 1126 1118 return 1; 1127 1119 } 1128 1120 return 0; 1129 1121 } ................................................................................ 1146 1138 case SCHEMA_CTYPE_CHOICE: 1147 1139 case SCHEMA_CTYPE_TEXT: 1148 1140 case SCHEMA_CTYPE_ANY: 1149 1141 /* Never pushed onto stack */ 1150 1142 Tcl_Panic ("Invalid CTYPE onto the validation stack!"); 1151 1143 1152 1144 case SCHEMA_CTYPE_INTERLEAVE: 1153 - mayskip = 1; 1145 + missing = 0; 1154 1146 for (i = 0; i < cp->nc; i++) { 1155 - if (se->interleaveState[i]) { 1156 - if (maxOne (cp->quants[i])) continue; 1157 - } else { 1158 - if (minOne (cp->quants[i])) mayskip = 0; 1159 - } 1147 + if (se->interleaveState[i] && maxOne (cp->quants[i])) 1148 + continue; 1160 1149 icp = cp->content[i]; 1161 1150 switch (icp->type) { 1162 1151 case SCHEMA_CTYPE_TEXT: 1163 - if (icp->nc) { 1164 - if (!checkText (interp, icp, "")) { 1165 - mayskip = 0; 1166 - } 1167 - } 1168 1152 break; 1169 1153 1170 1154 case SCHEMA_CTYPE_ANY: 1171 - if (icp->namespace && icp->namespace == namespace) { 1155 + if (icp->namespace && icp->namespace != namespace) { 1172 1156 break; 1173 1157 } 1174 1158 sdata->skipDeep = 1; 1175 - if (mayskip && minOne (cp->quants[i])) mayskip = 0; 1176 1159 se->hasMatched = 1; 1177 1160 se->interleaveState[i] = 1; 1178 1161 return 1; 1179 1162 1180 1163 case SCHEMA_CTYPE_NAME: 1181 1164 if (icp->name == name 1182 1165 && icp->namespace == namespace) { ................................................................................ 1196 1179 rc = matchElementStart (interp, sdata, name, namespace); 1197 1180 if (rc == 1) { 1198 1181 se->hasMatched = 1; 1199 1182 se->interleaveState[i] = 1; 1200 1183 return 1; 1201 1184 } 1202 1185 popStack (sdata); 1203 - if (mayskip && rc != -1) mayskip = 0; 1204 1186 break; 1205 1187 1206 1188 case SCHEMA_CTYPE_VIRTUAL: 1207 1189 Tcl_Panic ("Virtual constraint child of INTERLEAVE"); 1208 1190 break; 1209 1191 1210 1192 case SCHEMA_CTYPE_KEYSPACE_END: 1211 1193 case SCHEMA_CTYPE_KEYSPACE: 1212 1194 Tcl_Panic ("Keyspace constraint child of INTERLEAVE"); 1213 1195 break; 1214 1196 1215 1197 } 1198 + if (!missing && minOne (cp->quants[i])) missing = 1; 1216 1199 } 1217 - if (mayskip) break; 1218 - if (recover (interp, sdata, S("MISSING_ONE_OF_INTERLEAVE"), 1, ac)) { 1219 - return 1; 1200 + if (missing) { 1201 + if (recover (interp, sdata, S("MISSING_ONE_OF_INTERLEAVE"), 1, ac)) { 1202 + return 1; 1203 + } 1204 + return 0; 1220 1205 } 1221 - return 0; 1222 1206 } 1223 1207 return -1; 1224 1208 } 1225 1209 1226 1210 static void * 1227 1211 getNamespacePtr ( 1228 1212 SchemaData *sdata, ................................................................................ 1658 1642 } 1659 1643 while (ac < cp->nc) { 1660 1644 DBG(fprintf (stderr, "ac %d hm %d mayMiss: %d\n", 1661 1645 ac, hm, mayMiss (cp->quants[ac]))); 1662 1646 if (mayMiss (cp->quants[ac])) { 1663 1647 ac++; continue; 1664 1648 } 1665 - 1666 1649 switch (cp->content[ac]->type) { 1667 1650 case SCHEMA_CTYPE_KEYSPACE_END: 1668 1651 cp->content[ac]->keySpace->active--; 1669 1652 if (!cp->content[ac]->keySpace->active) { 1670 1653 if (cp->content[ac]->keySpace->unknownIDrefs) { 1671 1654 if (!recover (interp, sdata, S("UNKNOWN_KEYREF"), 0, 0)) { 1672 1655 return 0; ................................................................................ 4202 4185 * cmd. */ 4203 4186 pattern->content = MALLOC (sizeof (Tcl_Obj*) * (objc)); 4204 4187 for (i = 1; i < objc; i++) { 4205 4188 pattern->content[i-1] = (SchemaCP *) objv[i]; 4206 4189 Tcl_IncrRefCount (objv[i]); 4207 4190 } 4208 4191 pattern->nc = objc; 4209 - addToContent (sdata, pattern, SCHEMA_CQUANT_OPT, 0, 0); 4192 + addToContent (sdata, pattern, SCHEMA_CQUANT_ONE, 0, 0); 4210 4193 return TCL_OK; 4211 4194 } 4212 4195 4213 4196 static int 4214 4197 domuniquePatternObjCmd ( 4215 4198 ClientData clientData, 4216 4199 Tcl_Interp *interp,
Changes to tests/schema.test.
1524 1524 <doc><a/><a/><a/><c/></doc> 1525 1525 <doc><b/><b/><b/><c/></doc> 1526 1526 <doc><c/></doc> 1527 1527 } { 1528 1528 lappend result [s validate $xml] 1529 1529 } 1530 1530 set result 1531 -} {0 0 1 0 1 1 1} 1531 +} {0 0 1 0 1 1 0} 1532 1532 1533 1533 test schema-7.15a {choice with optional choices} { 1534 1534 tdom::schema create s 1535 1535 s define { 1536 1536 defelement doc { 1537 1537 choice { 1538 1538 element a * ................................................................................ 1614 1614 <doc><aa/><ab/><aa/><c/></doc> 1615 1615 <doc><aa/><ab/><aa/><aa/><ab/><c/></doc> 1616 1616 <doc><c/></doc> 1617 1617 } { 1618 1618 lappend result [s validate $xml] 1619 1619 } 1620 1620 set result 1621 -} {0 0 1 0 1 1 1 1 1} 1621 +} {0 0 1 0 1 1 1 1 0} 1622 1622 1623 1623 test schema-7.17 {choice with optional choices} { 1624 1624 tdom::schema create s 1625 1625 s define { 1626 1626 defelement doc { 1627 1627 choice { 1628 1628 element a * ................................................................................ 1648 1648 <doc><aa/><ab/><aa/><c/></doc> 1649 1649 <doc><aa/><ab/><aa/><aa/><ab/><c/></doc> 1650 1650 <doc><c/></doc> 1651 1651 } { 1652 1652 lappend result [s validate $xml] 1653 1653 } 1654 1654 set result 1655 -} {0 0 1 0 1 1 0 0 1} 1655 +} {0 0 1 0 1 1 0 0 0} 1656 1656 1657 1657 test schema-7.18 {choice} { 1658 1658 tdom::schema create s 1659 1659 s define { 1660 1660 defelement doc { 1661 1661 choice { 1662 1662 element a ................................................................................ 1730 1730 <doc><aa/><ab/><aa/><c/></doc> 1731 1731 <doc><aa/><ab/><aa/><aa/><ab/><c/></doc> 1732 1732 <doc><c/></doc> 1733 1733 } { 1734 1734 lappend result [s validate $xml] 1735 1735 } 1736 1736 set result 1737 -} {0 0 1 1 0 0 0 1 0 0 1} 1737 +} {0 0 1 1 0 0 0 1 0 0 0} 1738 1738 1739 1739 test schema-7.20 {group with only optional content} { 1740 1740 tdom::schema create s 1741 1741 s define { 1742 1742 defelement doc { 1743 1743 element a 1744 1744 group { ................................................................................ 4660 4660 <doc>12</doc> 4661 4661 } { 4662 4662 lappend result [s validate $xml] 4663 4663 } 4664 4664 s delete 4665 4665 set result 4666 4666 } {0 1 0 1 0 1 1 0} 4667 - 4668 4667 4669 4668 test schema-16.16 {interleave} { 4670 4669 tdom::schema s 4671 4670 s define { 4672 4671 foreach e {a b1 b11 b2 c} { 4673 4672 defelement $e {} 4674 4673 }