Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Added method info stack associate to request data associated with the associate definition script command. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | associate |
Files: | files | file ages | folders |
SHA3-256: |
b2ca5788d459a20adae22ab1bd158fba |
User & Date: | rolf 2020-01-21 00:54:49 |
Context
2020-01-21
| ||
00:57 | Added the schema definition command associate and the requesting method info stack associated, tests and doc. check-in: 254c84e47d user: rolf tags: schema | |
00:54 | Added method info stack associate to request data associated with the associate definition script command. Closed-Leaf check-in: b2ca5788d4 user: rolf tags: associate | |
2020-01-18
| ||
02:05 | Save work. check-in: 59815422e2 user: rolf tags: associate | |
Changes
Changes to doc/schema.html.
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 ... 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 ... 198 199 200 201 202 203 204 205 206 207 208 209 210 211 ... 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 ... 511 512 513 514 515 516 517 518 519 520 521 522 523 524 ... 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 ... 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 ... 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 ... 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 ... 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 .... 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 |
<html> <head> <link rel="stylesheet" href="manpage.css"><title>tDOM manual: schema</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) 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="#SECTid0x56426a691630">NAME</a> · <a href="#SECTid0x56426a5e2110">SYNOPSIS</a> · <a href="#SECTid0x56426a66f810">DESCRIPTION </a> · <a href="#SECTid0x56426a6cfdd0">Schema definition scripts</a> · <a href="#SECTid0x56426a6daa70">Quantity specifier</a> · <a href="#SECTid0x56426a6dc8c0">Text constraint scripts</a> · <a href="#SECTid0x56426a6ea940">Local key constraints</a> · <a href="#SECTid0x56426a6ec750">Exampels</a> </div><hr class="navsep"> </div><div class="body"> <h2><a name="SECTid0x56426a691630">NAME</a></h2><p class="namesection"> <b class="names">tdom::schema - </b><br>Create a schema validation command</p> <h2><a name="SECTid0x56426a5e2110">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="SECTid0x56426a66f810">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 data or to post-validate a tDOM DOM tree (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"> ................................................................................ <dt> <b>text</b> <i>text</i> </dt> <dd>Checks if the current validation state allows the given text content. It raises error, if not.</dd> </dl> </dd> <dt> <b class="method">validate</b> <i class="m"><XML string></i> <i class="m">?objVar?</i> </dt> <dd>Returns true if the <i class="m"><XML string></i> is valid or false otherwise. If validation failed and the optional <i class="m">objVar</i> argument is given, then the variable with that ................................................................................ and the optional <i class="m">objVar</i> argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional <i class="m">objVar</i> argument is given, then the variable with that name is set to the empty string.</dd> <dt> <b class="method">domvalidate</b> <i class="m">domNode</i> <i class="m">?objVar?</i> </dt> <dd>Returns true if the first argument is a valid tree or false otherwise. If validation failed and the optional <i class="m">objVar</i> argument is given, then the variable with that ................................................................................ <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="SECTid0x56426a6cfdd0">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 qualify the content as valid. It is a validation error if there is additional (not matched) content.</p><p>The schema definition commands are:</p><dl class="commandlist"> ................................................................................ <dd>Evaluates the Tcl script <i class="m">tclcmd arg arg ... </i> and the schema command appended to the argument list. This validation command is only allowed in strict sequential context (not in choice, mixed and interleave). If the return code is something else than 0 (TCL_OK) then this ia a validation error.</dd> <dt> <b class="method">prefixns</b> <i class="m">?prefixUriList?</i> </dt> <dd>This defines a prefix to namespace URI mapping exactly as a <i>schemacmd prefixns</i> call. This is meant as toplevel ................................................................................ will raise error, if you call it there.</dd> <dt> <b class="method">defelement</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> </dt> <dd>This defines an element type exactly as a <i>schemacmd defelement</i> 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> <dt> <b class="method">defpattern</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> </dt> <dd>This defines a named pattern exactly as a <i>schemacmd defpattern</i> call. This is meant as toplevel command of a ................................................................................ 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="SECTid0x56426a6daa70">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.</dd> ................................................................................ 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="SECTid0x56426a6dc8c0">Text constraint scripts</a></h2><p>Text - parsed character data, as XML calles it - must sometimes be of a certain kind, must comply to some rules etc to be valid. The text constraint script arguments to the text, attribute, nsattribute and deftext commands allow the following text constraint commands to check text for certain properties.</p><p>The text constraint commands are:</p><dl class="commandlist"> <dt> <b class="cmd">integer</b> <i class="m">?(xsd|tcl)?</i> ................................................................................ <dd>This text constraint match if the text value is a xsd:unsignedLong. This is an integer between 0 and 18446744073709551615, both included, optionally preceded by a + sign and leading zeros.</dd> </dl> <h2><a name="SECTid0x56426a6ea940">Local key constraints</a></h2><p>Document wide uniqueness and foreign key constraints are available with the text constraint commands id and idref. Keyspaces allow for sub-tree local uniqueness and foreign key constraints.</p><dl class="commandlist"> <dt> <b class="cmd">keyspace</b> <i class="m"><names list></i> <i class="m"><constraint script></i> </dt> ................................................................................ active always matches. If the keyspace is active then reports error if there is still no key as the value at the end of the keyspace <i class="m"><name></i>. Otherwise it matches.</dd> </dl> <h2><a name="SECTid0x56426a6ec750">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. ................................................................................ } foreach e {name email} { defelement $e {text} } } </pre> </div><hr class="navsep"><div class="navbar" align="center"> <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> </div> </body> </html> |
| | | | > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | > > > > > > > > > > > > > | > > > > > > > > > > > | | | | > > > > |
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 ... 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 ... 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 ... 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 ... 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 ... 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 ... 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 ... 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 ... 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 .... 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 .... 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 |
<html> <head> <link rel="stylesheet" href="manpage.css"><title>tDOM manual: schema</title><meta name="xsl-processor" content="Jochen Loewer (loewerj@hotmail.com), Rolf Ade (rolf@pointsman.de) 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="#SECTid0x5589be9ed630">NAME</a> · <a href="#SECTid0x5589be942120">SYNOPSIS</a> · <a href="#SECTid0x5589be9cb810">DESCRIPTION </a> · <a href="#SECTid0x5589bea2daf0">Schema definition scripts</a> · <a href="#SECTid0x5589bea39a30">Quantity specifier</a> · <a href="#SECTid0x5589bea3b880">Text constraint scripts</a> · <a href="#SECTid0x5589bea49900">Local key constraints</a> · <a href="#SECTid0x5589bea4b710">Exampels</a> · <a href="#SECTid0x5589bea4d6c0">KEYWORDS</a> </div><hr class="navsep"> </div><div class="body"> <h2><a name="SECTid0x5589be9ed630">NAME</a></h2><p class="namesection"> <b class="names">tdom::schema - </b><br>Create a schema validation command</p> <h2><a name="SECTid0x5589be942120">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="SECTid0x5589be9cb810">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 data or to post-validate a tDOM DOM tree (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"> ................................................................................ <dt> <b>text</b> <i>text</i> </dt> <dd>Checks if the current validation state allows the given text content. It raises error, if not.</dd> </dl> </dd> <dt> <b class="method">stack</b> <i class="m">(top|inside|associated)</i> </dt> <dd>In Tcl scripts evaluated by validation this method provides information about the current validation stack. Called outside this context the method returns the empty string. <dl class="optlist"> <dt><b>top</b></dt> <dd>Returns the element which content is currently checked (the at the moment open element tag). </dd> <dt><b>inside</b></dt> <dd>Returns all currently open elements as a list.</dd> <dt><b>associated</b></dt> <dd>Returns the data associated with the current top most stack content particle or the empty string it there isn't. </dd> </dl> </dd> <dt> <b class="method">validate</b> <i class="m"><XML string></i> <i class="m">?objVar?</i> </dt> <dd>Returns true if the <i class="m"><XML string></i> is valid or false otherwise. If validation failed and the optional <i class="m">objVar</i> argument is given, then the variable with that ................................................................................ and the optional <i class="m">objVar</i> argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional <i class="m">objVar</i> argument is given, then the variable with that name is set to the empty string.</dd> <dt> <b class="method">validatechannel</b> <i class="m">channel</i> <i class="m">?objVar?</i> </dt> <dd>Returns true if the content read ouf of the tcl channel <i class="m">channel</i> is valid or false otherwise. Since data read out of a tcl channel is UTF-8 encoded any misleading encoding declaration at the beginning of the data will lead to errors. If the validation failed and the optional <i class="m">objVar</i> argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional <i class="m">objVar</i> argument is given, then the variable with that name is set to the empty string.</dd> <dt> <b class="method">domvalidate</b> <i class="m">domNode</i> <i class="m">?objVar?</i> </dt> <dd>Returns true if the first argument is a valid tree or false otherwise. If validation failed and the optional <i class="m">objVar</i> argument is given, then the variable with that ................................................................................ <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="SECTid0x5589bea2daf0">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 qualify the content as valid. It is a validation error if there is additional (not matched) content.</p><p>The schema definition commands are:</p><dl class="commandlist"> ................................................................................ <dd>Evaluates the Tcl script <i class="m">tclcmd arg arg ... </i> and the schema command appended to the argument list. This validation command is only allowed in strict sequential context (not in choice, mixed and interleave). If the return code is something else than 0 (TCL_OK) then this ia a validation error.</dd> <dt> <b class="method">associate</b> <i class="m">data</i> </dt> <dd>This command is only allowed top-level inside the definition scripts of the element, elementtype, pattern or interleave content particle. Associate the as argument given <i class="m">data</i> with the currently defined content particle and may be requested in scripts evaluated while validating the content of that particle with the schema command method call <i class="m">info stack associated</i>.</dd> <dt> <b class="method">prefixns</b> <i class="m">?prefixUriList?</i> </dt> <dd>This defines a prefix to namespace URI mapping exactly as a <i>schemacmd prefixns</i> call. This is meant as toplevel ................................................................................ will raise error, if you call it there.</dd> <dt> <b class="method">defelement</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> </dt> <dd>This defines an element exactly as a <i>schemacmd defelement</i> 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> <dt> <b class="method">defelementtype</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> </dt> <dd>This defines an elementtype exactly as a <i>schemacmd defelementtype</i> 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> <dt> <b class="method">defpattern</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m"><definition script></i> </dt> <dd>This defines a named pattern exactly as a <i>schemacmd defpattern</i> call. This is meant as toplevel command of a ................................................................................ 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="SECTid0x5589bea39a30">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.</dd> ................................................................................ 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="SECTid0x5589bea3b880">Text constraint scripts</a></h2><p>Text - parsed character data, as XML calles it - must sometimes be of a certain kind, must comply to some rules etc to be valid. The text constraint script arguments to the text, attribute, nsattribute and deftext commands allow the following text constraint commands to check text for certain properties.</p><p>The text constraint commands are:</p><dl class="commandlist"> <dt> <b class="cmd">integer</b> <i class="m">?(xsd|tcl)?</i> ................................................................................ <dd>This text constraint match if the text value is a xsd:unsignedLong. This is an integer between 0 and 18446744073709551615, both included, optionally preceded by a + sign and leading zeros.</dd> </dl> <h2><a name="SECTid0x5589bea49900">Local key constraints</a></h2><p>Document wide uniqueness and foreign key constraints are available with the text constraint commands id and idref. Keyspaces allow for sub-tree local uniqueness and foreign key constraints.</p><dl class="commandlist"> <dt> <b class="cmd">keyspace</b> <i class="m"><names list></i> <i class="m"><constraint script></i> </dt> ................................................................................ active always matches. If the keyspace is active then reports error if there is still no key as the value at the end of the keyspace <i class="m"><name></i>. Otherwise it matches.</dd> </dl> <h2><a name="SECTid0x5589bea4b710">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. ................................................................................ } foreach e {name email} { defelement $e {text} } } </pre> <h2><a name="SECTid0x5589bea4d6c0">KEYWORDS</a></h2><p class="keywords"> <a class="keyword" href="keyword-index.html#KW-Validation">Validation</a>, <a class="keyword" href="keyword-index.html#KW-Postvalidation">Postvalidation</a>, <a class="keyword" href="keyword-index.html#KW-DOM">DOM</a>, <a class="keyword" href="keyword-index.html#KW-SAX">SAX</a> </p> </div><hr class="navsep"><div class="navbar" align="center"> <a class="navaid" href="index.html">Contents</a> · <a class="navaid" href="category-index.html">Index</a> · <a class="navaid" href="keyword-index.html">Keywords</a> · <a class="navaid" href="http://tdom.org">Repository</a> </div> </body> </html> |
Changes to doc/schema.n.
281 282 283 284 285 286 287 288 289 290 291 292 293 294 ... 300 301 302 303 304 305 306 307 308 309 310 311 312 313 ... 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 .... 1084 1085 1086 1087 1088 1089 1090 1091 |
Checks if the current innermost open element may end here in the current state without violate validation constrains. It raises error, if not. .IP "\fBtext \fItext\fP\fR" Checks if the current validation state allows the given text content. It raises error, if not. .RE .TP \&\fB\fBvalidate\fP \fI<XML string>\fB \fI?objVar?\fB \&\fRReturns true if the \fI<XML string>\fR is valid or false otherwise. If validation failed and the optional \&\fIobjVar\fR argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional \fIobjVar\fR argument is given, ................................................................................ to expat, therefor only US-ASCII, ISO-8859-1, UTF-8 or UTF-16 encoded data will work with this method. If validation failed and the optional \fIobjVar\fR argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional \fIobjVar\fR argument is given, then the variable with that name is set to the empty string. .TP \&\fB\fBdomvalidate\fP \fIdomNode\fB \fI?objVar?\fB \&\fRReturns true if the first argument is a valid tree or false otherwise. If validation failed and the optional \&\fIobjVar\fR argument is given, then the variable with that name is set to a validation error message. If the dom tree is valid and the optional \fIobjVar\fR argument is given, then ................................................................................ \&\fB\fBtcl\fP \fItclcmd\fB \fI?arg arg ...?\fB \&\fREvaluates the Tcl script \fItclcmd arg arg ... \fR and the schema command appended to the argument list. This validation command is only allowed in strict sequential context (not in choice, mixed and interleave). If the return code is something else than 0 (TCL_OK) then this ia a validation error. .TP \&\fB\fBprefixns\fP \fI?prefixUriList?\fB \&\fRThis defines a prefix to namespace URI mapping exactly as a \fIschemacmd prefixns\fR call. This is meant as toplevel command of a \fIschemacmd define\fR script. This command is not allowed nested in an other definition script command and will raise error, if you call it there. .TP \&\fB\fBdefelement\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB \&\fRThis defines an element type exactly as a \fIschemacmd defelement\fR call. This is meant as toplevel command of a \&\fIschemacmd define\fR script. This command is not allowed nested in an other definition script command and will raise error, if you call it there. .TP \&\fB\fBdefpattern\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB \&\fRThis defines a named pattern exactly as a \fIschemacmd defpattern\fR call. This is meant as toplevel command of a \&\fIschemacmd define\fR script. This command is not allowed nested in an other definition script command and will raise error, if you call it there. ................................................................................ foreach e {name email} { defelement $e {text} } } .CE |
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > | > |
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 ... 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 ... 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 .... 1127 1128 1129 1130 1131 1132 1133 1134 1135 |
Checks if the current innermost open element may end here in the current state without violate validation constrains. It raises error, if not. .IP "\fBtext \fItext\fP\fR" Checks if the current validation state allows the given text content. It raises error, if not. .RE .TP \&\fB\fBstack\fP \fI(top|inside|associated)\fB \&\fRIn Tcl scripts evaluated by validation this method provides information about the current validation stack. Called outside this context the method returns the empty string. .RS .IP "\fBtop\fR" Returns the element which content is currently checked (the at the moment open element tag). .IP "\fBinside\fR" Returns all currently open elements as a list. .IP "\fBassociated\fR" Returns the data associated with the current top most stack content particle or the empty string it there isn't. .RE .TP \&\fB\fBvalidate\fP \fI<XML string>\fB \fI?objVar?\fB \&\fRReturns true if the \fI<XML string>\fR is valid or false otherwise. If validation failed and the optional \&\fIobjVar\fR argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional \fIobjVar\fR argument is given, ................................................................................ to expat, therefor only US-ASCII, ISO-8859-1, UTF-8 or UTF-16 encoded data will work with this method. If validation failed and the optional \fIobjVar\fR argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional \fIobjVar\fR argument is given, then the variable with that name is set to the empty string. .TP \&\fB\fBvalidatechannel\fP \fIchannel\fB \fI?objVar?\fB \&\fRReturns true if the content read ouf of the tcl channel \&\fIchannel\fR is valid or false otherwise. Since data read out of a tcl channel is UTF-8 encoded any misleading encoding declaration at the beginning of the data will lead to errors. If the validation failed and the optional \fIobjVar\fR argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional \fIobjVar\fR argument is given, then the variable with that name is set to the empty string. .TP \&\fB\fBdomvalidate\fP \fIdomNode\fB \fI?objVar?\fB \&\fRReturns true if the first argument is a valid tree or false otherwise. If validation failed and the optional \&\fIobjVar\fR argument is given, then the variable with that name is set to a validation error message. If the dom tree is valid and the optional \fIobjVar\fR argument is given, then ................................................................................ \&\fB\fBtcl\fP \fItclcmd\fB \fI?arg arg ...?\fB \&\fREvaluates the Tcl script \fItclcmd arg arg ... \fR and the schema command appended to the argument list. This validation command is only allowed in strict sequential context (not in choice, mixed and interleave). If the return code is something else than 0 (TCL_OK) then this ia a validation error. .TP \&\fB\fBassociate\fP \fIdata\fB \&\fRThis command is only allowed top-level inside the definition scripts of the element, elementtype, pattern or interleave content particle. Associate the as argument given \&\fIdata\fR with the currently defined content particle and may be requested in scripts evaluated while validating the content of that particle with the schema command method call \&\fIinfo stack associated\fR. .TP \&\fB\fBprefixns\fP \fI?prefixUriList?\fB \&\fRThis defines a prefix to namespace URI mapping exactly as a \fIschemacmd prefixns\fR call. This is meant as toplevel command of a \fIschemacmd define\fR script. This command is not allowed nested in an other definition script command and will raise error, if you call it there. .TP \&\fB\fBdefelement\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB \&\fRThis defines an element exactly as a \fIschemacmd defelement\fR call. This is meant as toplevel command of a \&\fIschemacmd define\fR script. This command is not allowed nested in an other definition script command and will raise error, if you call it there. .TP \&\fB\fBdefelementtype\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB \&\fRThis defines an elementtype exactly as a \fIschemacmd defelementtype\fR call. This is meant as toplevel command of a \&\fIschemacmd define\fR script. This command is not allowed nested in an other definition script command and will raise error, if you call it there. .TP \&\fB\fBdefpattern\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB \&\fRThis defines a named pattern exactly as a \fIschemacmd defpattern\fR call. This is meant as toplevel command of a \&\fIschemacmd define\fR script. This command is not allowed nested in an other definition script command and will raise error, if you call it there. ................................................................................ foreach e {name email} { defelement $e {text} } } .CE .SH KEYWORDS Validation, Postvalidation, DOM, SAX |
Changes to doc/schema.xml.
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
...
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
|
<optdef> <optname>text</optname> <optarg>text</optarg> <desc>Checks if the current validation state allows the given text content. It raises error, if not.</desc> </optdef> </optlist> </desc> </commanddef> <commanddef> <command><method>validate</method> <m><XML string></m> <m>?objVar?</m></command> <desc>Returns true if the <m><XML string></m> is valid or false otherwise. If validation failed and the optional <m>objVar</m> argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional <m>objVar</m> argument is given, ................................................................................ <desc>Evaluates the Tcl script <m>tclcmd arg arg ... </m> and the schema command appended to the argument list. This validation command is only allowed in strict sequential context (not in choice, mixed and interleave). If the return code is something else than 0 (TCL_OK) then this ia a validation error.</desc> </commanddef> <commanddef> <command><method>prefixns</method> <m>?prefixUriList?</m></command> <desc>This defines a prefix to namespace URI mapping exactly as a <i>schemacmd prefixns</i> 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.</desc> </commanddef> <commanddef> <command><method>defelement</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> <desc>This defines an element type exactly as a <i>schemacmd defelement</i> 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.</desc> </commanddef> <commanddef> <command><method>defpattern</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> <desc>This defines a named pattern exactly as a <i>schemacmd defpattern</i> 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.</desc> |
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
|
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
...
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
|
<optdef> <optname>text</optname> <optarg>text</optarg> <desc>Checks if the current validation state allows the given text content. It raises error, if not.</desc> </optdef> </optlist> </desc> </commanddef> <commanddef> <command><method>stack</method> <m>(top|inside|associated)</m></command> <desc>In Tcl scripts evaluated by validation this method provides information about the current validation stack. Called outside this context the method returns the empty string. <optlist> <optdef> <optname>top</optname> <desc>Returns the element which content is currently checked (the at the moment open element tag). </desc> </optdef> <optdef> <optname>inside</optname> <desc>Returns all currently open elements as a list.</desc> </optdef> <optdef> <optname>associated</optname> <desc>Returns the data associated with the current top most stack content particle or the empty string it there isn't. </desc> </optdef> </optlist> </desc> </commanddef> <commanddef> <command><method>validate</method> <m><XML string></m> <m>?objVar?</m></command> <desc>Returns true if the <m><XML string></m> is valid or false otherwise. If validation failed and the optional <m>objVar</m> argument is given, then the variable with that name is set to a validation error message. If the XML string is valid and the optional <m>objVar</m> argument is given, ................................................................................ <desc>Evaluates the Tcl script <m>tclcmd arg arg ... </m> and the schema command appended to the argument list. This validation command is only allowed in strict sequential context (not in choice, mixed and interleave). If the return code is something else than 0 (TCL_OK) then this ia a validation error.</desc> </commanddef> <commanddef> <command><method>associate</method> <m>data</m></command> <desc>This command is only allowed top-level inside the definition scripts of the element, elementtype, pattern or interleave content particle. Associate the as argument given <m>data</m> with the currently defined content particle and may be requested in scripts evaluated while validating the content of that particle with the schema command method call <m>info stack associated</m>.</desc> </commanddef> <commanddef> <command><method>prefixns</method> <m>?prefixUriList?</m></command> <desc>This defines a prefix to namespace URI mapping exactly as a <i>schemacmd prefixns</i> 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.</desc> </commanddef> <commanddef> <command><method>defelement</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> <desc>This defines an element exactly as a <i>schemacmd defelement</i> 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.</desc> </commanddef> <commanddef> <command><method>defelementtype</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> <desc>This defines an elementtype exactly as a <i>schemacmd defelementtype</i> 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.</desc> </commanddef> <commanddef> <command><method>defpattern</method> <m>name</m> <m>?namespace?</m> <m><definition script></m></command> <desc>This defines a named pattern exactly as a <i>schemacmd defpattern</i> 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.</desc> |
Changes to generic/schema.c.
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
....
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
|
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_typedefinition, m_definedElementtypes }; static const char *schemaInstanceInfoStackMethods[] = { "top", "inside", NULL }; enum schemaInstanceInfoStackMethod { m_top, m_inside }; static const char *schemaInstanceInfoVactionMethods[] = { "name", "namespace", "text", NULL }; enum schemaInstanceInfoVactionMethod { m_name, m_namespace, m_text ................................................................................ } if (Tcl_GetIndexFromObj (interp, objv[2], schemaInstanceInfoStackMethods, "method", 0, &methodIndex) != TCL_OK) { return TCL_ERROR; } switch ((enum schemaInstanceInfoStackMethod) methodIndex) { case m_inside: if (!sdata->stack) { Tcl_ResetResult (interp); return TCL_OK; } se = sdata->stack; rObj = Tcl_NewObj(); while (se) { if (se->pattern->type == SCHEMA_CTYPE_NAME) { Tcl_ListObjAppendElement (interp, rObj, serializeElementName (interp, se->pattern)); } se = se->down; } Tcl_SetObjResult (interp, rObj); return TCL_OK; case m_top: if (!sdata->stack) { Tcl_ResetResult (interp); return TCL_OK; } se = sdata->stack; while (se->pattern->type != SCHEMA_CTYPE_NAME) { se = se->down; } rObj = serializeElementName (interp, se->pattern); Tcl_SetObjResult (interp, rObj); return TCL_OK; } case m_toplevel: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, ""); return TCL_ERROR; } |
|
|
<
<
|
<
|
|
|
>
>
<
<
<
<
<
>
>
>
>
>
>
>
|
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
....
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
|
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_typedefinition, m_definedElementtypes }; static const char *schemaInstanceInfoStackMethods[] = { "top", "inside", "associated", NULL }; enum schemaInstanceInfoStackMethod { m_top, m_inside, m_associated }; static const char *schemaInstanceInfoVactionMethods[] = { "name", "namespace", "text", NULL }; enum schemaInstanceInfoVactionMethod { m_name, m_namespace, m_text ................................................................................ } if (Tcl_GetIndexFromObj (interp, objv[2], schemaInstanceInfoStackMethods, "method", 0, &methodIndex) != TCL_OK) { return TCL_ERROR; } if (!sdata->stack) { return TCL_OK; } se = sdata->stack; switch ((enum schemaInstanceInfoStackMethod) methodIndex) { case m_inside: rObj = Tcl_NewObj(); while (se) { if (se->pattern->type == SCHEMA_CTYPE_NAME) { Tcl_ListObjAppendElement (interp, rObj, serializeElementName (interp, se->pattern)); } se = se->down; } Tcl_SetObjResult (interp, rObj); return TCL_OK; case m_top: while (se->pattern->type != SCHEMA_CTYPE_NAME) { se = se->down; } rObj = serializeElementName (interp, se->pattern); Tcl_SetObjResult (interp, rObj); return TCL_OK; case m_associated: if (!se->pattern->associated) { return TCL_OK; } Tcl_SetObjResult (interp, se->pattern->associated); return TCL_OK; } case m_toplevel: if (objc != 2) { Tcl_WrongNumArgs (interp, 2, objv, ""); return TCL_ERROR; } |
Changes to tests/schema.test.
6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 |
s delete set result } {defelementtype a b http://my.foo { elementtype a elementtype a2 }} proc schema-18 {args} { lappend ::result {*}$args } test schema-18.1 {reportcmd} { tdom::schema s s define { defelement doc { |
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > |
6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431 6432 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 6464 6465 |
s delete set result } {defelementtype a b http://my.foo { elementtype a elementtype a2 }} proc schema-17.19 {schemacmd} { lappend ::result [$schemacmd info stack associated] } test schema-17.19 {info stack associated} { tdom::schema s s defelement doc { element a + } s defelement a { associate "fo bar baz" tcl schema-17.19 } set result [list] foreach xml { <doc><a/></doc> <doc><a/><a/></doc> } { lappend result [s validate $xml] } s delete set result } {{fo bar baz} 1 {fo bar baz} {fo bar baz} 1} proc schema-17.20 {schemacmd args} { lappend ::result [$schemacmd info stack associated] } test schema-17.20 {info stack associated} { tdom::schema s s defelement doc { element a + } s defelement a { associate "fo bar baz" # Only local defined element b ? } s reportcmd schema-17.20 set result [list] foreach xml { <doc></doc> <doc><a/></doc> <doc><a><b/></a></doc> <doc><a><c/></a></doc> <doc><a/><b/></doc> } { lappend result [s validate $xml] } s delete set result } {{} 1 1 1 {fo bar baz} 1 {} 1} proc schema-18 {args} { lappend ::result {*}$args } test schema-18.1 {reportcmd} { tdom::schema s s define { defelement doc { |