Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added new text constraint command split, which splits the text to check into a list and cecks the elements of that list against the given constraints. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | schema |
Files: | files | file ages | folders |
SHA3-256: |
77cf4c70906c99a58eb85d69dab69fc7 |
User & Date: | rolf 2019-05-02 12:14:20.468 |
Context
2019-05-02
| ||
16:53 | Added text constraint commands id and idref. check-in: a886296dc3 user: rolf tags: schema | |
12:14 | Added new text constraint command split, which splits the text to check into a list and cecks the elements of that list against the given constraints. check-in: 77cf4c7090 user: rolf tags: schema | |
12:11 | Done. Closed-Leaf check-in: 9a631db368 user: rolf tags: wip | |
2019-04-27
| ||
00:50 | Added documentation for the strip text constraint command. check-in: d441a1e8b1 user: rolf tags: schema | |
Changes
Changes to doc/schema.html.
1 2 3 4 5 6 | <html> <head> <link rel="stylesheet" href="manpage.css"><title>tDOM manual: schema</title><meta name="xsl-processor" content="Jochen Loewer ([email protected]), Rolf Ade ([email protected]) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> </head><body> <div class="header"> <div class="navbar" align="center"> | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <html> <head> <link rel="stylesheet" href="manpage.css"><title>tDOM manual: schema</title><meta name="xsl-processor" content="Jochen Loewer ([email protected]), Rolf Ade ([email protected]) et. al."><meta name="generator" content="$RCSfile: tmml-html.xsl,v $ $Revision: 1.11 $"><meta charset="utf-8"> </head><body> <div class="header"> <div class="navbar" align="center"> <a href="#SECTid0x55d81f852b30">NAME</a> · <a href="#SECTid0x55d81f853160">SYNOPSIS</a> · <a href="#SECTid0x55d81f84d5d0">DESCRIPTION </a> · <a href="#SECTid0x55d81f8ab7e0">Schema definition scripts</a> · <a href="#SECTid0x55d81f8b3b10">Quantity specifier</a> · <a href="#SECTid0x55d81f8b59a0">Text constraint scripts</a> · <a href="#SECTid0x55d81f8bcfc0">Exampels</a> </div><hr class="navsep"> </div><div class="body"> <h2><a name="SECTid0x55d81f852b30">NAME</a></h2><p class="namesection"> <b class="names">tdom::schema - </b><br>Create a schema validation command</p> <h2><a name="SECTid0x55d81f853160">SYNOPSIS</a></h2><pre class="syntax">package require tdom <b class="cmd">tdom::schema</b> <i class="m">?create?</i> <i class="m">cmdName</i> </pre> <h2><a name="SECTid0x55d81f84d5d0">DESCRIPTION </a></h2><p>This command creates validation commands with a simple API. The validation commands have methods to define a schema and are able to validate XML or DOM trees (and to some degree other kind of hierarchical data) against this schema.</p><p>Additionally, a validation command may be used as argument to the <i class="m">-validateCmd</i> option of the <i class="m">dom parse</i> and the <i class="m">expat</i> commands to enable validation additional to what they otherwise do.</p><p>The valid methods of the created commands are:</p><dl class="commandlist"> |
︙ | ︙ | |||
165 166 167 168 169 170 171 | <dt><b class="method">reset</b></dt> <dd>This method resets the validation command into state READY (while preserving the defined grammer).</dd> </dl> | | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | <dt><b class="method">reset</b></dt> <dd>This method resets the validation command into state READY (while preserving the defined grammer).</dd> </dl> <h2><a name="SECTid0x55d81f8ab7e0">Schema definition scripts</a></h2><p>Schema definition scripts are ordinary Tcl scripts that are evaluatend in the namespace tdom::schema. The below listed schema definition commands in this tcl namespace allow to define a wide variety of document structures. Every schema definition command establish a validation constraint on the content which has to match or must be optional to render the content as valid. It is a validation error if the element in the XML source has additional (not matched) content.</p><p>The schema definition commands are:</p><dl class="commandlist"> |
︙ | ︙ | |||
315 316 317 318 319 320 321 | call. This is meant as toplevel command of a <i>schemacmd define</i> script. This command is not allowed nested in an other definition script command and will raise error, if you call it there.</dd> </dl> | | | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | call. This is meant as toplevel command of a <i>schemacmd define</i> script. This command is not allowed nested in an other definition script command and will raise error, if you call it there.</dd> </dl> <h2><a name="SECTid0x55d81f8b3b10">Quantity specifier</a></h2><p>Serveral schema definition commands expects a quantifier as one of their arguments, which specifies how often the content particle specified by the command is expected. The valid values for a <i class="m">quant</i> argument are:</p><dl class="optlist"> <dt><b>!</b></dt> <dd>The content particle must occur exactly once in valid documents. This is the default, if a quantifier is |
︙ | ︙ | |||
360 361 362 363 364 365 366 | n to m times (both inclusive) in a row in valid documents. The quantifier must be a tcl list with two elements. Both elements must be integers, with n >= 0 and n < m.</dd> </dl><p>If an optional quantifier is not given then it defaults to * in case of the mixed command and to ! for all other commands.</p> | | | 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | n to m times (both inclusive) in a row in valid documents. The quantifier must be a tcl list with two elements. Both elements must be integers, with n >= 0 and n < m.</dd> </dl><p>If an optional quantifier is not given then it defaults to * in case of the mixed command and to ! for all other commands.</p> <h2><a name="SECTid0x55d81f8b59a0">Text constraint scripts</a></h2><p></p><p>The text constraint commands are:</p><dl class="commandlist"> <dt><b class="cmd">isint</b></dt> <dd></dd> <dt> |
︙ | ︙ | |||
477 478 479 480 481 482 483 484 | <dt> <b class="cmd">strip</b> <i class="m"><constraint script></i> </dt> <dd>This text constraint command tests all text constraints in the evaluated <i class="m">constraint script></i> with the text to test striped of all white space at start and end.</dd> | > > > > > > > > > > > > > > > > > > > | > > > | > > | | 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | <dt> <b class="cmd">strip</b> <i class="m"><constraint script></i> </dt> <dd>This text constraint command tests all text constraints in the evaluated <i class="m">constraint script></i> with the text to test striped of all white space at start and end.</dd> <dt> <b class="cmd">split</b> <i class="m">?type ?args??</i><i class="m"><constraint script></i> </dt> <dd> <p>This text constraint command splits the text to test into a list of values and tests all elements of that list for the text constraints in the evaluated <i class="m">constraint script></i>.</p> <p>The available types are:</p> <dl> <dt>whitespace</dt><dd>The text to split is striped of all white space at start and end splited into a list at any successive white space.</dd> <dt>tcl tclcmd ?arg ...?</dt><dd>The text to split is handed to the <i class="m">tclcmd</i>, which is evaluated on global level, appended with every given arg and the text to split as last argument. This call must return a valid tcl list, which elements are tested..</dd> </dl> <p>The default in case no split type argument is given is <i class="m">whitespace</i>.</p> </dd> </dl> <h2><a name="SECTid0x55d81f8bcfc0">Exampels</a></h2><p>The XML Schema Part 0: Primer Second Edition (<a href="https://www.w3.org/TR/xmlschema-0/">https://www.w3.org/TR/xmlschema-0/</a>) starts with this example schema:</p><pre class="example"> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:annotation> <xsd:documentation xml:lang="en"> Purchase order schema for Example.com. |
︙ | ︙ |
Changes to doc/schema.n.
︙ | ︙ | |||
495 496 497 498 499 500 501 502 503 504 505 506 507 508 | useful mostly together with the \fIoneOf\fR text constraint commmand. .TP \&\fB\fBstrip\fP \fI<constraint script>\fB \&\fRThis text constraint command tests all text constraints in the evaluated \fIconstraint script>\fR with the text to test striped of all white space at start and end. .SH Exampels .PP .UR "https://www.w3.org/TR/xmlschema-0/" <URL: https://www.w3.org/TR/xmlschema-0/> .UE The XML Schema Part 0: Primer Second Edition () starts with this | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 | useful mostly together with the \fIoneOf\fR text constraint commmand. .TP \&\fB\fBstrip\fP \fI<constraint script>\fB \&\fRThis text constraint command tests all text constraints in the evaluated \fIconstraint script>\fR with the text to test striped of all white space at start and end. .TP \&\fB\fBsplit\fP \fI?type ?args??\fB\fI<constraint script>\fB \&\fR .RS .PP This text constraint command splits the text to test into a list of values and tests all elements of that list for the text constraints in the evaluated \fIconstraint script>\fR. .PP The available types are: .TP whitespace The text to split is striped of all white space at start and end splited into a list at any successive white space. .TP tcl tclcmd ?arg ...? The text to split is handed to the \fItclcmd\fR, which is evaluated on global level, appended with every given arg and the text to split as last argument. This call must return a valid tcl list, which elements are tested.. .PP The default in case no split type argument is given is \&\fIwhitespace\fR. .RE .SH Exampels .PP .UR "https://www.w3.org/TR/xmlschema-0/" <URL: https://www.w3.org/TR/xmlschema-0/> .UE The XML Schema Part 0: Primer Second Edition () starts with this |
︙ | ︙ |
Changes to doc/schema.xml.
︙ | ︙ | |||
441 442 443 444 445 446 447 448 449 450 451 452 453 454 | </commanddef> <commanddef> <command><cmd>strip</cmd> <m><constraint script></m></command> <desc>This text constraint command tests all text constraints in the evaluated <m>constraint script></m> with the text to test striped of all white space at start and end.</desc> </commanddef> </commandlist> </section> <section> <title>Exampels</title> <p>The XML Schema Part 0: Primer Second Edition | > > > > > > > > > > > > > > > > > > > > | 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | </commanddef> <commanddef> <command><cmd>strip</cmd> <m><constraint script></m></command> <desc>This text constraint command tests all text constraints in the evaluated <m>constraint script></m> with the text to test striped of all white space at start and end.</desc> </commanddef> <commanddef> <command><cmd>split</cmd> <m>?type ?args??</m><m><constraint script></m></command> <desc><p>This text constraint command splits the text to test into a list of values and tests all elements of that list for the text constraints in the evaluated <m>constraint script></m>.</p> <p>The available types are:</p> <dl> <dt>whitespace</dt><dd>The text to split is striped of all white space at start and end splited into a list at any successive white space.</dd> <dt>tcl tclcmd ?arg ...?</dt><dd>The text to split is handed to the <m>tclcmd</m>, which is evaluated on global level, appended with every given arg and the text to split as last argument. This call must return a valid tcl list, which elements are tested..</dd> </dl> <p>The default in case no split type argument is given is <m>whitespace</m>.</p></desc> </commanddef> </commandlist> </section> <section> <title>Exampels</title> <p>The XML Schema Part 0: Primer Second Edition |
︙ | ︙ |
Changes to generic/schema.c.
︙ | ︙ | |||
97 98 99 100 101 102 103 104 105 106 107 108 109 110 | #define SetResult3(str1,str2,str3) Tcl_ResetResult(interp); \ Tcl_AppendResult(interp, (str1), (str2), (str3), NULL) #define SetIntResult(i) Tcl_ResetResult(interp); \ Tcl_SetIntObj(Tcl_GetObjResult(interp), (i)) #define SetBooleanResult(i) Tcl_ResetResult(interp); \ Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (i)) #define checkNrArgs(l,h,err) if (objc < l || objc > h) { \ SetResult (err); \ return TCL_ERROR; \ } #if defined(DEBUG) || defined(DDEBUG) static char *Schema_CP_Type2str[] = { | > > | 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | #define SetResult3(str1,str2,str3) Tcl_ResetResult(interp); \ Tcl_AppendResult(interp, (str1), (str2), (str3), NULL) #define SetIntResult(i) Tcl_ResetResult(interp); \ Tcl_SetIntObj(Tcl_GetObjResult(interp), (i)) #define SetBooleanResult(i) Tcl_ResetResult(interp); \ Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (i)) #define SPACE(c) ((c) == ' ' || (c) == '\n' || (c )== '\t' || (c) == '\r') #define checkNrArgs(l,h,err) if (objc < l || objc > h) { \ SetResult (err); \ return TCL_ERROR; \ } #if defined(DEBUG) || defined(DDEBUG) static char *Schema_CP_Type2str[] = { |
︙ | ︙ | |||
1590 1591 1592 1593 1594 1595 1596 | candidate = cp->content[ac]; switch (candidate->type) { case SCHEMA_CTYPE_TEXT: if (checkText (interp, candidate, text)) { updateStack (se, cp, ac); return 1; } | > | > | 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 | candidate = cp->content[ac]; switch (candidate->type) { case SCHEMA_CTYPE_TEXT: if (checkText (interp, candidate, text)) { updateStack (se, cp, ac); return 1; } if (!sdata->evalError) { SetResult ("Invalid text content"); } return 0; case SCHEMA_CTYPE_CHOICE: if (candidate->flags & MIXED_CONTENT) { updateStack (se, cp, ac); return 1; } |
︙ | ︙ | |||
1769 1770 1771 1772 1773 1774 1775 | if (only_whites) return TCL_OK; if (matchText (interp, sdata, text)) { return TCL_OK; } } if (recover (interp, sdata, S("WRONG_VALUE"))) { return TCL_OK; | | > | > | 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 | if (only_whites) return TCL_OK; if (matchText (interp, sdata, text)) { return TCL_OK; } } if (recover (interp, sdata, S("WRONG_VALUE"))) { return TCL_OK; } if (!sdata->evalError) { SetResult ("Text content doesn't match"); } return TCL_ERROR; } static void startElement( void *userData, const char *name, |
︙ | ︙ | |||
3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 | Tcl_IncrRefCount (tcdata->evalStub[tcdata->nrArg-1]); tcdata->sdata->currentEvals++; result = Tcl_EvalObjv (interp, tcdata->nrArg, tcdata->evalStub, TCL_EVAL_GLOBAL); tcdata->sdata->currentEvals--; Tcl_DecrRefCount (tcdata->evalStub[tcdata->nrArg-1]); if (result != TCL_OK) { return 0; } result = Tcl_GetBooleanFromObj (interp, Tcl_GetObjResult (interp), &bool); if (result != TCL_OK) { return 0; } if (bool) { | > | 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 | Tcl_IncrRefCount (tcdata->evalStub[tcdata->nrArg-1]); tcdata->sdata->currentEvals++; result = Tcl_EvalObjv (interp, tcdata->nrArg, tcdata->evalStub, TCL_EVAL_GLOBAL); tcdata->sdata->currentEvals--; Tcl_DecrRefCount (tcdata->evalStub[tcdata->nrArg-1]); if (result != TCL_OK) { tcdata->sdata->evalError = 1; return 0; } result = Tcl_GetBooleanFromObj (interp, Tcl_GetObjResult (interp), &bool); if (result != TCL_OK) { return 0; } if (bool) { |
︙ | ︙ | |||
4086 4087 4088 4089 4090 4091 4092 | char *text ) { SchemaCP *cp = (SchemaCP *) constraintData; int rc, restore = 0; char *end, saved; | | | | 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 | char *text ) { SchemaCP *cp = (SchemaCP *) constraintData; int rc, restore = 0; char *end, saved; while(SPACE((unsigned char)*text)) text++; if(*text != 0) { /* Not white space only */ /* Trim trailing space */ end = text + strlen(text) - 1; while(end > text && SPACE((unsigned char)*end)) end--; saved = end[1]; restore = 1; end[1] = '\0'; } rc = checkText (interp, cp, text); if (restore) end[1] = saved; return rc; |
︙ | ︙ | |||
4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 | ADD_CONSTRAINT (sdata, sc) sc->constraint = stripImpl; sc->constraintData = (void *)cp; return TCL_OK; } return TCL_ERROR; } void tDOM_SchemaInit ( Tcl_Interp *interp ) { /* Inline definition commands. */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 | ADD_CONSTRAINT (sdata, sc) sc->constraint = stripImpl; sc->constraintData = (void *)cp; return TCL_OK; } return TCL_ERROR; } static int splitWhitespaceImpl ( Tcl_Interp *interp, void *constraintData, char *text ) { SchemaCP *cp = (SchemaCP *) constraintData; int rc = 0; char *p, *end, saved = 0; p = text; while (*p != 0) { while(SPACE (*p)) p++; if (*p == 0) break; end = p; end++; while (*end != 0 && !SPACE(*end)) end++; saved = *end; *end = 0; rc = checkText (interp, cp, p); *end = saved; p = end; if (!rc) break; } return rc; } typedef struct { int nrArg; Tcl_Obj **evalStub; SchemaData *sdata; SchemaCP *cp; } splitTclTCData; static int splitTclImpl ( Tcl_Interp *interp, void *constraintData, char *text ) { splitTclTCData *tcdata = (splitTclTCData *) constraintData; int rc, listlen, i; Tcl_Obj *list, *listelm; tcdata->evalStub[tcdata->nrArg-1] = Tcl_NewStringObj(text, -1); Tcl_IncrRefCount (tcdata->evalStub[tcdata->nrArg-1]); tcdata->sdata->currentEvals++; rc = Tcl_EvalObjv (interp, tcdata->nrArg, tcdata->evalStub, TCL_EVAL_GLOBAL); tcdata->sdata->currentEvals--; Tcl_DecrRefCount (tcdata->evalStub[tcdata->nrArg-1]); if (rc != TCL_OK) { tcdata->sdata->evalError = 1; return 0; } list = Tcl_GetObjResult (interp); Tcl_IncrRefCount (list); Tcl_ResetResult (interp); if (Tcl_ListObjLength (interp, list, &listlen) != TCL_OK) { Tcl_DecrRefCount (list); tcdata->sdata->evalError = 1; return 0; } rc = 0; for (i = 0; i < listlen; i++) { Tcl_ListObjIndex (interp, list, i, &listelm); rc = checkText (interp, tcdata->cp, Tcl_GetString (listelm)); if (!rc) break; } Tcl_DecrRefCount (list); return rc; } static void splitTclImplFree ( void *constraintData ) { splitTclTCData *tcdata = constraintData; int i; for (i = 0; i < tcdata->nrArg-1; i++) { Tcl_DecrRefCount (tcdata->evalStub[i]); } FREE (tcdata->evalStub); FREE (tcdata); } static int splitTCObjCmd ( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[] ) { SchemaData *sdata = GETASI; SchemaCP *cp; SchemaConstraint *sc; int methodIndex, rc, i; splitTclTCData *tcdata; static const char *methods[] = { "whitespace", "tcl", NULL }; enum method { m_whitespace, m_tcl }; CHECK_TI CHECK_TOPLEVEL if (objc < 2) { SetResult("Expected: ?type ?args?? <text constraint script>"); return TCL_ERROR; } if (objc == 2) { methodIndex = m_whitespace; } else { if (Tcl_GetIndexFromObj (interp, objv[1], methods, "type", 0, &methodIndex) != TCL_OK) { return TCL_ERROR; } } switch ((enum method) methodIndex) { case m_whitespace: if (objc > 2) { SetResult ("Type whitespace expects no argument."); return TCL_ERROR; } break; case m_tcl: if (objc < 3) { SetResult ("Expected: tclcmd ?arg ...?."); return TCL_ERROR; } } cp = initSchemaCP (SCHEMA_CTYPE_CHOICE, NULL, NULL); cp->type = SCHEMA_CTYPE_TEXT; REMEMBER_PATTERN (cp) rc = evalConstraints (interp, sdata, cp, objv[objc-1]); if (rc != TCL_OK) { return TCL_ERROR; } ADD_CONSTRAINT (sdata, sc) switch ((enum method) methodIndex) { case m_whitespace: sc->constraint = splitWhitespaceImpl; sc->constraintData = cp; break; case m_tcl: sc->constraint = splitTclImpl; sc->freeData = splitTclImplFree; tcdata = TMALLOC (splitTclTCData); tcdata->nrArg = objc - 2; tcdata->evalStub = MALLOC (sizeof (Tcl_Obj*) * (objc-2)); for (i = 2; i < objc -1; i++) { tcdata->evalStub[i-2] = objv[i]; Tcl_IncrRefCount (tcdata->evalStub[i-2]); } tcdata->sdata = sdata; tcdata->cp = cp; sc->constraintData = tcdata; } return TCL_OK; } void tDOM_SchemaInit ( Tcl_Interp *interp ) { /* Inline definition commands. */ |
︙ | ︙ | |||
4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 | minLengthTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp,"tdom::schema::text::oneOf", oneOfTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp,"tdom::schema::text::allOf", allOfTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp,"tdom::schema::text::strip", stripTCObjCmd, NULL, NULL); } #endif /* #ifndef TDOM_NO_SCHEMA */ | > > | 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 | minLengthTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp,"tdom::schema::text::oneOf", oneOfTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp,"tdom::schema::text::allOf", allOfTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp,"tdom::schema::text::strip", stripTCObjCmd, NULL, NULL); Tcl_CreateObjCommand (interp,"tdom::schema::text::split", splitTCObjCmd, NULL, NULL); } #endif /* #ifndef TDOM_NO_SCHEMA */ |
Changes to tests/schema.test.
︙ | ︙ | |||
3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 | {<a> 12 34 </a>} } { lappend result [s validate $xml] } s delete set result } {0 0 0 0 1 1 1 1 1 0 1} test schema-15.1 {constraint cmd tcl} { tdom::schema s s define { defelement a { tcl append ::schema-15.1 element b | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 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 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 | {<a> 12 34 </a>} } { lappend result [s validate $xml] } s delete set result } {0 0 0 0 1 1 1 1 1 0 1} test schema-14.22 {split} { tdom::schema s s define { defelement doc { element a 1 { text { split { number } } } } } set result [list] foreach xml { <doc><a/></doc> <doc><a></a></doc> {<doc><a> </a></doc>} {<doc><a>1</a></doc>} {<doc><a>-2.1</a></doc>} {<doc><a> -2.1 </a></doc>} {<doc><a>-a</a></doc>} {<doc><a>-a b c</a></doc>} {<doc><a> 1 2 3.5</a></doc>} {<doc><a> 1 a 3.5</a></doc>} {<doc><a>1 2 fooo</a></doc>} {<doc><a>1 2 fooo </a></doc>} } { lappend result [s validate $xml] } s delete set result } {0 0 0 1 1 1 0 0 1 0 0 0} proc schema-14.23 {text} { return [split $text] } test schema-14.23 {split} { tdom::schema s s define { defelement doc { element a 1 { text { split tcl schema-14.23 { number } } } } } set result [list] foreach xml { <doc><a/></doc> <doc><a></a></doc> {<doc><a> </a></doc>} {<doc><a>1</a></doc>} {<doc><a>-2.1</a></doc>} {<doc><a> -2.1 </a></doc>} {<doc><a>-a</a></doc>} {<doc><a>-a b c</a></doc>} {<doc><a>1 2 3.5</a></doc>} {<doc><a> 1 a 3.5</a></doc>} {<doc><a>1 2 fooo</a></doc>} {<doc><a>1 2 3 -4.5</a></doc>} } { lappend result [s validate $xml errMsg] } s delete set result } {0 0 0 1 1 0 0 0 0 0 0 1} proc schema-14.24 {text} { global schema-14.24 switch ${schema-14.24} { 1 {return {1 2 3}} 2 {return {-23.4 .5}} 3 {return {0 a 5}} default {error "Unexpected value of the global var schema-14.24."} } } test schema-14.24 {split} { set schema-14.24 0 tdom::schema s s define { defelement doc { element a 1 { text { split tcl schema-14.24 { number } } } } } set result [list] foreach xml { {<doc><a> </a></doc>} {<doc><a>-a</a></doc>} {<doc><a>1 2 3 -4.5</a></doc>} } { incr schema-14.24 lappend result [s validate $xml errMsg] } s delete set result } {1 1 0} proc schema-14.24a {arg1 arg2 text} { global schema-14.24a if {$arg1 ne "foo" || $arg2 ne "bar"} { error "Unexpected args" } switch ${schema-14.24a} { 1 {return {1 2 3}} 2 {return {-23.4 .5}} 3 {return {0 a 5}} default {error "Unexpected value of the global var schema-14.24."} } } test schema-14.24a {split} { set schema-14.24a 0 tdom::schema s s define { defelement doc { element a 1 { text { split tcl schema-14.24a foo bar { number } } } } } set result [list] foreach xml { {<doc><a> </a></doc>} {<doc><a>-a</a></doc>} {<doc><a>1 2 3 -4.5</a></doc>} } { incr schema-14.24a lappend result [s validate $xml] } s delete set result } {1 1 0} test schema-15.1 {constraint cmd tcl} { tdom::schema s s define { defelement a { tcl append ::schema-15.1 element b |
︙ | ︙ |