Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added documentation for the schema command methods defelementtype and validatefile.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: c9e4b5af68a3996b1297e917d9e6771b457b10e1b7cd45c71e04ce025d8a5e8d
User & Date: rolf 2019-12-31 02:37:49
Original Comment: Added documentation for the schema command methods defeleemnttype and validatefile.
Context
2020-01-01
23:53
Added some index keywords to the schema documentation. check-in: d2f4f6bacf user: rolf tags: schema
2019-12-31
02:37
Added documentation for the schema command methods defelementtype and validatefile. check-in: c9e4b5af68 user: rolf tags: schema
02:06
Added schema command method validatefile. check-in: cb70253aed user: rolf tags: schema
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

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
..
52
53
54
55
56
57
58






















59
60
61
62
63
64
65
...
104
105
106
107
108
109
110
111

112
113
114
115
116
117
118
119
120
121
...
160
161
162
163
164
165
166















167
168
169
170
171
172
173
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
...
282
283
284
285
286
287
288
289

290
291
292
293
294
295
296
...
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
...
438
439
440
441
442
443
444
445

446
447
448
449
450
451
452
...
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
...
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
...
590
591
592
593
594
595
596




































597
598
599
600
601
602
603
...
646
647
648
649
650
651
652



























653
654
655
656
657
658
659
...
775
776
777
778
779
780
781



































782
783
784
785
786
787
788
789
790
791
...
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
<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="#SECTid0x56384972a920">NAME</a> · <a href="#SECTid0x563849693ab0">SYNOPSIS</a> · <a href="#SECTid0x563849721800">DESCRIPTION </a> · <a href="#SECTid0x56384977fad0">Schema definition scripts</a> · <a href="#SECTid0x56384978a700">Quantity specifier</a> · <a href="#SECTid0x56384978c550">Text constraint scripts</a> · <a href="#SECTid0x563849796360">Local key constraints</a> · <a href="#SECTid0x563849798170">Exampels</a>
</div><hr class="navsep">
</div><div class="body">
  <h2><a name="SECTid0x56384972a920">NAME</a></h2><p class="namesection">
<b class="names">tdom::schema - </b><br>Create a schema validation command</p>

  <h2><a name="SECTid0x563849693ab0">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="SECTid0x563849721800">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">
................................................................................
        model of the element. If the <i class="m">namespace</i> argument is
        given, any <i class="m">element</i> or <i class="m">ref</i> references in the
        definition script not wrapped inside a <i class="m">namespace</i>
        command are resolved in that namespace. If there is already a
        element definition for the name/namespace combination the
        command raises error.</dd>
      























      
        <dt>
<b class="method">defpattern</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m">&lt;definition script&gt;</i>
</dt>
        <dd>This method defines a (maybe complex) content particle
        with the <i class="m">name</i> (optional in the namespace
................................................................................

      
        <dt>
<b class="method">define</b> <i class="m">&lt;definition script&gt;</i>
</dt>
        <dd>This method allows to define several elements or pattern
        or a whole schema with one call. All schema command methods so
        far (<i class="m">prefixns</i>, <i class="m">defelement</i>, <i class="m">defpattern</i>,

        <i class="m">deftext</i> and <i class="m">start</i>) are allowed top level in the
        <i class="m">definition script</i>. The <i class="m">define</i> method itself
        isn't allowed recursively.</dd>
      
      
      
        <dt>
<b class="method">event</b> <i class="m">(start|end|text)</i> <i class="m">?event specific data?</i>
</dt>
        <dd>This method allows to validate hierarchical data against
................................................................................
        false otherwise. If 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>line</b></dt>
                  <dd>If the schema command is currently validating
                  this method returns the line part of the parsing
                  position information and the empty string in all
                  other cases. If the schema command is currently
                  post-validating a DOM tree there may be not position
                  information stored at certain or all nodes. The
                  empty string is returned in this cases.</dd>
              
              
                  <dt><b>column</b></dt>
                  <dd>If the schema command is currently validating
                  this method returns the column part of the parsing
                  position information and the empty string in all
                  other cases. If the schema command is currently
                  post-validating a DOM tree there may be not position
                  information stored at certain or all nodes. The
                  empty string is returned in this cases.</dd>
              
              
                  <dt><b>domNode</b></dt>
                  <dd>If the schema command is currently
                  post-validating a DOM tree ist command returns the
                  current parent node command (the node, whose content
                  is currently validated) and the empty string
                  otherwhise. It is recommended that you don't use
                  this method. Or at least leaf the DOM tree alone,
                  use it read-only.</dd>
              
              
                  <dt><b>nrForwardDefinitions</b></dt>
                  <dd>Returns the at least used once referenced
                  element and ref particles that aren't defined so far
                  (summed together).</dd>
................................................................................
                  <dt><b>vaction ?name|namespace|text?</b></dt>
                  <dd>If the schema command is currently processing
                  a validation event this method returns information
                  about what the command is doing. If the command is
                  called without the optional argument the possible
                  return values and their meanings are:
                  <dl>
                      <dt>NONE</dt><dd></dd>

                      <dt>MATCH_ELEMENT_START</dt><dd></dd>
                      <dt>MATCH_ELEMENT_END</dt><dd></dd>
                      <dt>MATCH_TEXT</dt><dd></dd>
                      <dt>MATCH_ATTRIBUTE_TEXT</dt><dd></dd>
                      <dt>MATCH_GLOBAL</dt><dd></dd>
                      <dt>MATCH_DOM_KEYCONSTRAINT</dt><dd></dd>
                  </dl>
................................................................................
        <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="SECTid0x56384977fad0">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">
      
................................................................................
        <i class="m">name</i> argument there may be one of the quantifieres ? or
        !. If there is, this will be used. Otherwise the attribute
        will be required (must be present in the xml source). If there
        is one argument more this argument is evaluated as constraint
        script, defining the value constrains of the attribute.
        Otherwise, if there are two more arguments and the first of
        them is the bareword "type" then the following is used as a
        text type name.</dd>

      

      
        <dt>
<b class="method">nsattribute</b> <i class="m">name</i> <i class="m">namespace</i> <i class="m">?quant?</i> <i class="m">(?&lt;constraint script&gt;|"type" typename?)</i>
</dt>
        <dd>This command does the same as the command
................................................................................
        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="SECTid0x56384978a700">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 &gt;= 0 and n &lt; 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="SECTid0x56384978c550">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>
................................................................................
        is <i class="m">tcl</i> everthing that returns TCL_OK if feeded into
        Tcl_GetInt() matches. If the optional argument to the command
        is <i class="m">xsd</i> then the constraint match if the value is a
        valid xsd:integer. Without argument <i class="m">xsd</i> is the
        default.</dd>
      





































      
        <dt>
<b class="cmd">fixed</b> <i class="m">value</i>
</dt>
        <dd>The text constraint only match if the text value is
        string equal to the given value.</dd>
      
................................................................................
      
        <dt><b class="cmd">nmtokens</b></dt>
        <dd>This text constraint match if the text value match the
        XML nmtokens production
        <a href="https://www.w3.org/TR/xml/#NT-Nmtokens">https://www.w3.org/TR/xml/#NT-Nmtokens</a>
</dd>
      



























      
        <dt>
<b class="cmd">number</b> <i class="m">?(xsd|tcl)?</i>
</dt>
        <dd>This text constraint match if the text value could be
        parsed as a number. If the optional argument to the command is
        <i class="m">tcl</i> everthing that returns TCL_OK if feeded into
................................................................................
        references within the document to one ID are possible.</dd>
      
      
        <dt><b class="cmd">base64</b></dt>
        <dd>This text constraint match if text is valid according to
        RFC 4648.</dd>
      



































    </dl>

  <h2><a name="SECTid0x563849796360">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">&lt;names list&gt;</i> <i class="m">&lt;constraint script&gt;</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">&lt;name&gt;</i>. Otherwise it
            matches.</dd>
        
    </dl>

  <h2><a name="SECTid0x563849798170">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">
&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;

  &lt;xsd:annotation&gt;
    &lt;xsd:documentation xml:lang="en"&gt;
     Purchase order schema for Example.com.






|


|


|




|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>
|
|
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|









|






|



|







 







|
>







 







|







 







|
>







 







|







 







|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|







 







|







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
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
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
...
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
...
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
...
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
...
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
...
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
...
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
...
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
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
<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">
................................................................................
        model of the element. If the <i class="m">namespace</i> argument is
        given, any <i class="m">element</i> or <i class="m">ref</i> references in the
        definition script not wrapped inside a <i class="m">namespace</i>
        command are resolved in that namespace. If there is already a
        element definition for the name/namespace combination the
        command raises error.</dd>
      

      
        <dt>
<b class="method">defelementtype</b> <i class="m">typename</i> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m">&lt;definition script&gt;</i>
</dt>
        <dd>This method defines the elementtype <i class="m">typename</i>
        (optional in the namespace <i class="m">namespace</i>) in the schema. If
        the element type is refered in a definition script with the
        schema command elementype the validation engine expects an
        elment namend <i class="m">name</i> (in the namespace <i class="m">namespace</i>,
        if given) and the content model <i class="m">definition script</i>.
        Defining element types seems only sensible if you really have
        elments with the same name and namespache but different
        content models. The <i class="m">definition script</i> is evaluated and
        defines the content model of the element. If the
        <i class="m">namespace</i> argument is given, any <i class="m">element</i> or
        <i class="m">ref</i> references in the definition script not wrapped
        inside a <i class="m">namespace</i> command are resolved in that
        namespace. If there is already a elementtype definition for
        the name/namespace combination the command raises
        error.</dd>
      

      
        <dt>
<b class="method">defpattern</b> <i class="m">name</i> <i class="m">?namespace?</i> <i class="m">&lt;definition script&gt;</i>
</dt>
        <dd>This method defines a (maybe complex) content particle
        with the <i class="m">name</i> (optional in the namespace
................................................................................

      
        <dt>
<b class="method">define</b> <i class="m">&lt;definition script&gt;</i>
</dt>
        <dd>This method allows to define several elements or pattern
        or a whole schema with one call. All schema command methods so
        far (<i class="m">prefixns</i>, <i class="m">defelement</i>,
        <i class="m">defelementtype</i>, <i class="m">defpattern</i>, <i class="m">deftext</i> and
        <i class="m">start</i>) are allowed top level in the <i class="m">definition
        script</i>. The <i class="m">define</i> method itself isn't allowed
        recursively.</dd>
      
      
      
        <dt>
<b class="method">event</b> <i class="m">(start|end|text)</i> <i class="m">?event specific data?</i>
</dt>
        <dd>This method allows to validate hierarchical data against
................................................................................
        false otherwise. If 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">validatefile</b> <i class="m">filename</i> <i class="m">?objVar?</i>
</dt>
        <dd>Returns true if the content of <i class="m">filename</i> is valid
        or false otherwise. The given file is feeded as binary stream
        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 <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>line</b></dt>
                  <dd>If the schema command is currently validating
                  this method returns the line part of the parsing
                  position information and the empty string in all
                  other cases. If the schema command is currently
                  post-validating a DOM tree there may be no position
                  information stored at certain or all nodes. The
                  empty string is returned in this cases.</dd>
              
              
                  <dt><b>column</b></dt>
                  <dd>If the schema command is currently validating
                  this method returns the column part of the parsing
                  position information and the empty string in all
                  other cases. If the schema command is currently
                  post-validating a DOM tree there may be no position
                  information stored at certain or all nodes. The
                  empty string is returned in this cases.</dd>
              
              
                  <dt><b>domNode</b></dt>
                  <dd>If the schema command is currently
                  post-validating a DOM tree this command returns the
                  current parent node command (the node, whose content
                  is currently validated) and the empty string
                  otherwhise. It is recommended that you don't use
                  this method. Or at least leave the DOM tree alone,
                  use it read-only.</dd>
              
              
                  <dt><b>nrForwardDefinitions</b></dt>
                  <dd>Returns the at least used once referenced
                  element and ref particles that aren't defined so far
                  (summed together).</dd>
................................................................................
                  <dt><b>vaction ?name|namespace|text?</b></dt>
                  <dd>If the schema command is currently processing
                  a validation event this method returns information
                  about what the command is doing. If the command is
                  called without the optional argument the possible
                  return values and their meanings are:
                  <dl>
                      <dt>NONE</dt><dd>The schema command currently
                      doesn't process a validation event.</dd>
                      <dt>MATCH_ELEMENT_START</dt><dd></dd>
                      <dt>MATCH_ELEMENT_END</dt><dd></dd>
                      <dt>MATCH_TEXT</dt><dd></dd>
                      <dt>MATCH_ATTRIBUTE_TEXT</dt><dd></dd>
                      <dt>MATCH_GLOBAL</dt><dd></dd>
                      <dt>MATCH_DOM_KEYCONSTRAINT</dt><dd></dd>
                  </dl>
................................................................................
        <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">
      
................................................................................
        <i class="m">name</i> argument there may be one of the quantifieres ? or
        !. If there is, this will be used. Otherwise the attribute
        will be required (must be present in the xml source). If there
        is one argument more this argument is evaluated as constraint
        script, defining the value constrains of the attribute.
        Otherwise, if there are two more arguments and the first of
        them is the bareword "type" then the following is used as a
        text type name. This command is only allowed at top level in
        the definition script of an defelement/element script.</dd>
      

      
        <dt>
<b class="method">nsattribute</b> <i class="m">name</i> <i class="m">namespace</i> <i class="m">?quant?</i> <i class="m">(?&lt;constraint script&gt;|"type" typename?)</i>
</dt>
        <dd>This command does the same as the command
................................................................................
        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 &gt;= 0 and n &lt; 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>
................................................................................
        is <i class="m">tcl</i> everthing that returns TCL_OK if feeded into
        Tcl_GetInt() matches. If the optional argument to the command
        is <i class="m">xsd</i> then the constraint match if the value is a
        valid xsd:integer. Without argument <i class="m">xsd</i> is the
        default.</dd>
      

      
        <dt>
<b class="cmd">negativeInteger</b> <i class="m">?(xsd|tcl)?</i>
</dt>
        <dd>This text constraint match the same text values as the
        <i class="m">integer</i> text constraint (see there) with the additional
        constraint that the value must be &lt; zero.</dd>
      
      
      
        <dt>
<b class="cmd">nonNegativeInteger</b> <i class="m">?(xsd|tcl)?</i>
</dt>
        <dd>This text constraint match the same text values as the
        <i class="m">integer</i> text constraint (see there) with the additional
        constraint that the value must be &gt;= zero.</dd>
      

      
        <dt>
<b class="cmd">nonPositiveInteger</b> <i class="m">?(xsd|tcl)?</i>
</dt>
        <dd>This text constraint match the same text values as the
        <i class="m">integer</i> text constraint (see there) with the additional
        constraint that the value must be &lt;= zero.</dd>
      

      
        <dt>
<b class="cmd">positiveInteger</b> <i class="m">?(xsd|tcl)?</i>
</dt>
        <dd>This text constraint match the same text values as the
        <i class="m">integer</i> text constraint (see there) with the additional
        constraint that the value must be &gt; zero.</dd>
      
      
      
        <dt>
<b class="cmd">fixed</b> <i class="m">value</i>
</dt>
        <dd>The text constraint only match if the text value is
        string equal to the given value.</dd>
      
................................................................................
      
        <dt><b class="cmd">nmtokens</b></dt>
        <dd>This text constraint match if the text value match the
        XML nmtokens production
        <a href="https://www.w3.org/TR/xml/#NT-Nmtokens">https://www.w3.org/TR/xml/#NT-Nmtokens</a>
</dd>
      
      
        <dt><b class="cmd">name</b></dt>
        <dd>This text constraint match if the text value match the
        XML name production
        <a href="https://www.w3.org/TR/xml/#NT-Name">https://www.w3.org/TR/xml/#NT-Name</a>. This means the
        text value must start with a letter, underscore (_), or colon (:),
        and may contain only letters, digits, underscores (_), colons
        (:), hyphens (-), and periods (.).</dd>
      
      
        <dt><b class="cmd">ncname</b></dt>
        <dd>This text constraint match if the text value match the
        XML ncname production
        <a href="https://www.w3.org/TR/xml-names/#NT-NCName">https://www.w3.org/TR/xml-names/#NT-NCName</a>. This
        means the text value must start with a letter or underscore (_),
        and may contain only letters, digits, underscores (_), hyphens
        (-), and periods (.) (The only difference to the name
        constraint is that colons are not permitted.)</dd>
      
      
        <dt><b class="cmd">qname</b></dt>
        <dd>This text constraint match if the text value match the
        XML qname production
        <a href="https://www.w3.org/TR/xml-names/#NT-QName">https://www.w3.org/TR/xml-names/#NT-QName</a>. This
        means the text value is either a ncname or two ncnames joined
        by a colon (:).</dd>
      
      
        <dt>
<b class="cmd">number</b> <i class="m">?(xsd|tcl)?</i>
</dt>
        <dd>This text constraint match if the text value could be
        parsed as a number. If the optional argument to the command is
        <i class="m">tcl</i> everthing that returns TCL_OK if feeded into
................................................................................
        references within the document to one ID are possible.</dd>
      
      
        <dt><b class="cmd">base64</b></dt>
        <dd>This text constraint match if text is valid according to
        RFC 4648.</dd>
      
      
        <dt><b class="cmd">hexBinary</b></dt>
        <dd>This text constraint match if text is a sequence of
        binary octets in hexadecimal encoding, where each binary octet
        is a two-character hexadecimal number. Lowercase and uppercase
        letters A through F are permitted.</dd>
      
      
        <dt><b class="cmd">unsignedByte</b></dt>
        <dd>This text constraint match if the text value is a
        xsd:unsignedByte. This is an integer between 0 and 255, both
        included, optionally preceded by a + sign and leading
        zeros.</dd>
      
      
        <dt><b class="cmd">unsignedShort</b></dt>
        <dd>This text constraint match if the text value is a
        xsd:unsignedShort. This is an integer between 0 and 65535,
        both included, optionally preceded by a + sign and leading
        zeros.</dd>
      
      
        <dt><b class="cmd">unsignedInt</b></dt>
        <dd>This text constraint match if the text value is a
        xsd:unsignedInt. This is an integer between 0 and 4294967295,
        both included, optionally preceded by a + sign and leading
        zeros.</dd>
      
      
        <dt><b class="cmd">unsignedLong</b></dt>
        <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">&lt;names list&gt;</i> <i class="m">&lt;constraint script&gt;</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">&lt;name&gt;</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">
&lt;xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;

  &lt;xsd:annotation&gt;
    &lt;xsd:documentation xml:lang="en"&gt;
     Purchase order schema for Example.com.

Changes to doc/schema.n.

204
205
206
207
208
209
210


















211
212
213
214
215
216
217
...
241
242
243
244
245
246
247
248

249
250
251
252
253
254
255
256
257
258
...
270
271
272
273
274
275
276











277
278
279
280
281
282
283
...
311
312
313
314
315
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
341
342
...
372
373
374
375
376
377
378


379
380
381
382
383
384
385
...
496
497
498
499
500
501
502
503

504
505
506
507
508
509
510
...
600
601
602
603
604
605
606




















607
608
609
610
611
612
613
...
643
644
645
646
647
648
649

































650
651
652
653
654
655
656
...
746
747
748
749
750
751
752






























753
754
755
756
757
758
759
\&\fIdefinition script\fR is evaluated and defines the content
model of the element. If the \fInamespace\fR argument is
given, any \fIelement\fR or \fIref\fR references in the
definition script not wrapped inside a \fInamespace\fR
command are resolved in that namespace. If there is already a
element definition for the name/namespace combination the
command raises error.


















.TP
\&\fB\fBdefpattern\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB
\&\fRThis method defines a (maybe complex) content particle
with the \fIname\fR (optional in the namespace
\&\fInamespace\fR) in the schema, to be referenced in other
definition scripts with the definition command \fIref\fR. The
\&\fIdefinition script\fR is evaluated and defines the content
................................................................................
empty string (and no namespace argument), the validation
constrain for the root element is removed and any defined
element will be valid as root of a tree to validate.
.TP
\&\fB\fBdefine\fP \fI<definition script>\fB
\&\fRThis method allows to define several elements or pattern
or a whole schema with one call. All schema command methods so
far (\fIprefixns\fR, \fIdefelement\fR, \fIdefpattern\fR,

\&\fIdeftext\fR and \fIstart\fR) are allowed top level in the
\&\fIdefinition script\fR. The \fIdefine\fR method itself
isn't allowed recursively.
.TP
\&\fB\fBevent\fP \fI(start|end|text)\fB \fI?event specific data?\fB
\&\fRThis method allows to validate hierarchical data against
the content constrains of the validation command.
.RS
.IP "\fBstart  \fIname ?attributes? ?namespace? \fP\fR"
Checks if the current validation state allows the
................................................................................
\&\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,
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
................................................................................
.IP "\fBvstate\fR"
This method is a shorter alias for validationstate; see there.
.IP "\fBline\fR"
If the schema command is currently validating
this method returns the line part of the parsing
position information and the empty string in all
other cases. If the schema command is currently
post-validating a DOM tree there may be not position
information stored at certain or all nodes. The
empty string is returned in this cases.
.IP "\fBcolumn\fR"
If the schema command is currently validating
this method returns the column part of the parsing
position information and the empty string in all
other cases. If the schema command is currently
post-validating a DOM tree there may be not position
information stored at certain or all nodes. The
empty string is returned in this cases.
.IP "\fBdomNode\fR"
If the schema command is currently
post-validating a DOM tree ist command returns the
current parent node command (the node, whose content
is currently validated) and the empty string
otherwhise. It is recommended that you don't use
this method. Or at least leaf the DOM tree alone,
use it read-only.
.IP "\fBnrForwardDefinitions\fR"
Returns the at least used once referenced
element and ref particles that aren't defined so far
(summed together).
.IP "\fBdefinedElements\fR"
Returns in no particular order the defined
................................................................................
a validation event this method returns information
about what the command is doing. If the command is
called without the optional argument the possible
return values and their meanings are:
.RS
.TP
NONE


.TP
MATCH_ELEMENT_START
.TP
MATCH_ELEMENT_END
.TP
MATCH_TEXT
.TP
................................................................................
\&\fIname\fR argument there may be one of the quantifieres ? or
!. If there is, this will be used. Otherwise the attribute
will be required (must be present in the xml source). If there
is one argument more this argument is evaluated as constraint
script, defining the value constrains of the attribute.
Otherwise, if there are two more arguments and the first of
them is the bareword "type" then the following is used as a
text type name.

.TP
\&\fB\fBnsattribute\fP \fIname\fB \fInamespace\fB \fI?quant?\fB \fI(?<constraint script>|\*(lqtype\*(lq typename?)\fB
\&\fRThis command does the same as the command
\&\fIattribute\fR, just for the attribute \fIname\fR in the
namespace \fInamespace\fR.
.TP
\&\fB\fBnamespace\fP \fIuri\fB \fI<definition script>\fB
................................................................................
parsed as an integer. If the optional argument to the command
is \fItcl\fR everthing that returns TCL_OK if feeded into
Tcl_GetInt() matches. If the optional argument to the command
is \fIxsd\fR then the constraint match if the value is a
valid xsd:integer. Without argument \fIxsd\fR is the
default.
.TP




















\&\fB\fBfixed\fP \fIvalue\fB
\&\fRThe text constraint only match if the text value is
string equal to the given value.
.TP
\&\fB\fBtcl\fP \fItclcmd\fB \fI?arg arg ...?\fB
\&\fREvaluates the tcl script \fItclcmd arg arg ... \fR and
the text to validate appended to the argument list. The return
................................................................................
.TP
\&\fB\fBnmtokens\fP
.UR "https://www.w3.org/TR/xml/#NT-Nmtokens"
<URL: https://www.w3.org/TR/xml/#NT-Nmtokens>
.UE
\&\fRThis text constraint match if the text value match the
XML nmtokens production

































.TP
\&\fB\fBnumber\fP \fI?(xsd|tcl)?\fB
\&\fRThis text constraint match if the text value could be
parsed as a number. If the optional argument to the command is
\&\fItcl\fR everthing that returns TCL_OK if feeded into
Tcl_GetDouble() matches. If the optional argument to the command
is \fIxsd\fR then the constraint match if the value is a
................................................................................
reference to an ID within the document. The referenced ID may
be later in the document, that the reference. Several
references within the document to one ID are possible.
.TP
\&\fB\fBbase64\fP
\&\fRThis text constraint match if text is valid according to
RFC 4648.






























.SH "Local key constraints"
.PP
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.
.TP







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>
|
|
|







 







>
>
>
>
>
>
>
>
>
>
>







 







|







|




|



|







 







>
>







 







|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
...
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
...
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
...
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
...
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
...
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
...
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
...
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
\&\fIdefinition script\fR is evaluated and defines the content
model of the element. If the \fInamespace\fR argument is
given, any \fIelement\fR or \fIref\fR references in the
definition script not wrapped inside a \fInamespace\fR
command are resolved in that namespace. If there is already a
element definition for the name/namespace combination the
command raises error.
.TP
\&\fB\fBdefelementtype\fP \fItypename\fB \fIname\fB \fI?namespace?\fB \fI<definition script>\fB
\&\fRThis method defines the elementtype \fItypename\fR
(optional in the namespace \fInamespace\fR) in the schema. If
the element type is refered in a definition script with the
schema command elementype the validation engine expects an
elment namend \fIname\fR (in the namespace \fInamespace\fR,
if given) and the content model \fIdefinition script\fR.
Defining element types seems only sensible if you really have
elments with the same name and namespache but different
content models. The \fIdefinition script\fR is evaluated and
defines the content model of the element. If the
\&\fInamespace\fR argument is given, any \fIelement\fR or
\&\fIref\fR references in the definition script not wrapped
inside a \fInamespace\fR command are resolved in that
namespace. If there is already a elementtype definition for
the name/namespace combination the command raises
error.
.TP
\&\fB\fBdefpattern\fP \fIname\fB \fI?namespace?\fB \fI<definition script>\fB
\&\fRThis method defines a (maybe complex) content particle
with the \fIname\fR (optional in the namespace
\&\fInamespace\fR) in the schema, to be referenced in other
definition scripts with the definition command \fIref\fR. The
\&\fIdefinition script\fR is evaluated and defines the content
................................................................................
empty string (and no namespace argument), the validation
constrain for the root element is removed and any defined
element will be valid as root of a tree to validate.
.TP
\&\fB\fBdefine\fP \fI<definition script>\fB
\&\fRThis method allows to define several elements or pattern
or a whole schema with one call. All schema command methods so
far (\fIprefixns\fR, \fIdefelement\fR,
\&\fIdefelementtype\fR, \fIdefpattern\fR, \fIdeftext\fR and
\&\fIstart\fR) are allowed top level in the \fIdefinition
script\fR. The \fIdefine\fR method itself isn't allowed
recursively.
.TP
\&\fB\fBevent\fP \fI(start|end|text)\fB \fI?event specific data?\fB
\&\fRThis method allows to validate hierarchical data against
the content constrains of the validation command.
.RS
.IP "\fBstart  \fIname ?attributes? ?namespace? \fP\fR"
Checks if the current validation state allows the
................................................................................
\&\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,
then the variable with that name is set to the empty string.
.TP
\&\fB\fBvalidatefile\fP \fIfilename\fB \fI?objVar?\fB
\&\fRReturns true if the content of \fIfilename\fR is valid
or false otherwise. The given file is feeded as binary stream
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
................................................................................
.IP "\fBvstate\fR"
This method is a shorter alias for validationstate; see there.
.IP "\fBline\fR"
If the schema command is currently validating
this method returns the line part of the parsing
position information and the empty string in all
other cases. If the schema command is currently
post-validating a DOM tree there may be no position
information stored at certain or all nodes. The
empty string is returned in this cases.
.IP "\fBcolumn\fR"
If the schema command is currently validating
this method returns the column part of the parsing
position information and the empty string in all
other cases. If the schema command is currently
post-validating a DOM tree there may be no position
information stored at certain or all nodes. The
empty string is returned in this cases.
.IP "\fBdomNode\fR"
If the schema command is currently
post-validating a DOM tree this command returns the
current parent node command (the node, whose content
is currently validated) and the empty string
otherwhise. It is recommended that you don't use
this method. Or at least leave the DOM tree alone,
use it read-only.
.IP "\fBnrForwardDefinitions\fR"
Returns the at least used once referenced
element and ref particles that aren't defined so far
(summed together).
.IP "\fBdefinedElements\fR"
Returns in no particular order the defined
................................................................................
a validation event this method returns information
about what the command is doing. If the command is
called without the optional argument the possible
return values and their meanings are:
.RS
.TP
NONE
The schema command currently
doesn't process a validation event.
.TP
MATCH_ELEMENT_START
.TP
MATCH_ELEMENT_END
.TP
MATCH_TEXT
.TP
................................................................................
\&\fIname\fR argument there may be one of the quantifieres ? or
!. If there is, this will be used. Otherwise the attribute
will be required (must be present in the xml source). If there
is one argument more this argument is evaluated as constraint
script, defining the value constrains of the attribute.
Otherwise, if there are two more arguments and the first of
them is the bareword "type" then the following is used as a
text type name. This command is only allowed at top level in
the definition script of an defelement/element script.
.TP
\&\fB\fBnsattribute\fP \fIname\fB \fInamespace\fB \fI?quant?\fB \fI(?<constraint script>|\*(lqtype\*(lq typename?)\fB
\&\fRThis command does the same as the command
\&\fIattribute\fR, just for the attribute \fIname\fR in the
namespace \fInamespace\fR.
.TP
\&\fB\fBnamespace\fP \fIuri\fB \fI<definition script>\fB
................................................................................
parsed as an integer. If the optional argument to the command
is \fItcl\fR everthing that returns TCL_OK if feeded into
Tcl_GetInt() matches. If the optional argument to the command
is \fIxsd\fR then the constraint match if the value is a
valid xsd:integer. Without argument \fIxsd\fR is the
default.
.TP
\&\fB\fBnegativeInteger\fP \fI?(xsd|tcl)?\fB
\&\fRThis text constraint match the same text values as the
\&\fIinteger\fR text constraint (see there) with the additional
constraint that the value must be < zero.
.TP
\&\fB\fBnonNegativeInteger\fP \fI?(xsd|tcl)?\fB
\&\fRThis text constraint match the same text values as the
\&\fIinteger\fR text constraint (see there) with the additional
constraint that the value must be >= zero.
.TP
\&\fB\fBnonPositiveInteger\fP \fI?(xsd|tcl)?\fB
\&\fRThis text constraint match the same text values as the
\&\fIinteger\fR text constraint (see there) with the additional
constraint that the value must be <= zero.
.TP
\&\fB\fBpositiveInteger\fP \fI?(xsd|tcl)?\fB
\&\fRThis text constraint match the same text values as the
\&\fIinteger\fR text constraint (see there) with the additional
constraint that the value must be > zero.
.TP
\&\fB\fBfixed\fP \fIvalue\fB
\&\fRThe text constraint only match if the text value is
string equal to the given value.
.TP
\&\fB\fBtcl\fP \fItclcmd\fB \fI?arg arg ...?\fB
\&\fREvaluates the tcl script \fItclcmd arg arg ... \fR and
the text to validate appended to the argument list. The return
................................................................................
.TP
\&\fB\fBnmtokens\fP
.UR "https://www.w3.org/TR/xml/#NT-Nmtokens"
<URL: https://www.w3.org/TR/xml/#NT-Nmtokens>
.UE
\&\fRThis text constraint match if the text value match the
XML nmtokens production
.TP
\&\fB\fBname\fP
.UR "https://www.w3.org/TR/xml/#NT-Name"
<URL: https://www.w3.org/TR/xml/#NT-Name>
.UE
\&\fRThis text constraint match if the text value match the
XML name production
\&. This means the
text value must start with a letter, underscore (_), or colon (:),
and may contain only letters, digits, underscores (_), colons
(:), hyphens (-), and periods (.).
.TP
\&\fB\fBncname\fP
.UR "https://www.w3.org/TR/xml-names/#NT-NCName"
<URL: https://www.w3.org/TR/xml-names/#NT-NCName>
.UE
\&\fRThis text constraint match if the text value match the
XML ncname production
\&. This
means the text value must start with a letter or underscore (_),
and may contain only letters, digits, underscores (_), hyphens
(-), and periods (.) (The only difference to the name
constraint is that colons are not permitted.)
.TP
\&\fB\fBqname\fP
.UR "https://www.w3.org/TR/xml-names/#NT-QName"
<URL: https://www.w3.org/TR/xml-names/#NT-QName>
.UE
\&\fRThis text constraint match if the text value match the
XML qname production
\&. This
means the text value is either a ncname or two ncnames joined
by a colon (:).
.TP
\&\fB\fBnumber\fP \fI?(xsd|tcl)?\fB
\&\fRThis text constraint match if the text value could be
parsed as a number. If the optional argument to the command is
\&\fItcl\fR everthing that returns TCL_OK if feeded into
Tcl_GetDouble() matches. If the optional argument to the command
is \fIxsd\fR then the constraint match if the value is a
................................................................................
reference to an ID within the document. The referenced ID may
be later in the document, that the reference. Several
references within the document to one ID are possible.
.TP
\&\fB\fBbase64\fP
\&\fRThis text constraint match if text is valid according to
RFC 4648.
.TP
\&\fB\fBhexBinary\fP
\&\fRThis text constraint match if text is a sequence of
binary octets in hexadecimal encoding, where each binary octet
is a two-character hexadecimal number. Lowercase and uppercase
letters A through F are permitted.
.TP
\&\fB\fBunsignedByte\fP
\&\fRThis text constraint match if the text value is a
xsd:unsignedByte. This is an integer between 0 and 255, both
included, optionally preceded by a + sign and leading
zeros.
.TP
\&\fB\fBunsignedShort\fP
\&\fRThis text constraint match if the text value is a
xsd:unsignedShort. This is an integer between 0 and 65535,
both included, optionally preceded by a + sign and leading
zeros.
.TP
\&\fB\fBunsignedInt\fP
\&\fRThis text constraint match if the text value is a
xsd:unsignedInt. This is an integer between 0 and 4294967295,
both included, optionally preceded by a + sign and leading
zeros.
.TP
\&\fB\fBunsignedLong\fP
\&\fRThis 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.
.SH "Local key constraints"
.PP
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.
.TP

Changes to doc/schema.xml.

54
55
56
57
58
59
60




















61
62
63
64
65
66
67
..
97
98
99
100
101
102
103
104

105
106
107
108
109
110
111
112
113
114
...
145
146
147
148
149
150
151













152
153
154
155
156
157
158
        given, any <m>element</m> or <m>ref</m> references in the
        definition script not wrapped inside a <m>namespace</m>
        command are resolved in that namespace. If there is already a
        element definition for the name/namespace combination the
        command raises error.</desc>
      </commanddef>





















      <commanddef>
        <command><method>defpattern</method> <m>name</m> <m>?namespace?</m> <m>&lt;definition script></m></command>
        <desc>This method defines a (maybe complex) content particle
        with the <m>name</m> (optional in the namespace
        <m>namespace</m>) in the schema, to be referenced in other
        definition scripts with the definition command <m>ref</m>. The
        <m>definition script</m> is evaluated and defines the content
................................................................................
        element will be valid as root of a tree to validate.</desc>
      </commanddef>

      <commanddef>
        <command><method>define</method> <m>&lt;definition script></m></command>
        <desc>This method allows to define several elements or pattern
        or a whole schema with one call. All schema command methods so
        far (<m>prefixns</m>, <m>defelement</m>, <m>defpattern</m>,

        <m>deftext</m> and <m>start</m>) are allowed top level in the
        <m>definition script</m>. The <m>define</m> method itself
        isn't allowed recursively.</desc>
      </commanddef>
      
      <commanddef>
        <command><method>event</method> <m>(start|end|text)</m> <m>?event specific data?</m></command>
        <desc>This method allows to validate hierarchical data against
        the content constrains of the validation command.

................................................................................
        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,
        then the variable with that name is set to the empty string.</desc>
      </commanddef>














      <commanddef>
        <command><method>domvalidate</method> <m>domNode</m> <m>?objVar?</m></command>
        <desc>Returns true if the first argument is a valid tree 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 dom tree is
        valid and the optional <m>objVar</m> argument is given, then







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
>
|
|
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
...
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
        given, any <m>element</m> or <m>ref</m> references in the
        definition script not wrapped inside a <m>namespace</m>
        command are resolved in that namespace. If there is already a
        element definition for the name/namespace combination the
        command raises error.</desc>
      </commanddef>

      <commanddef>
        <command><method>defelementtype</method> <m>typename</m> <m>name</m> <m>?namespace?</m> <m>&lt;definition script></m></command>
        <desc>This method defines the elementtype <m>typename</m>
        (optional in the namespace <m>namespace</m>) in the schema. If
        the element type is refered in a definition script with the
        schema command elementype the validation engine expects an
        elment namend <m>name</m> (in the namespace <m>namespace</m>,
        if given) and the content model <m>definition script</m>.
        Defining element types seems only sensible if you really have
        elments with the same name and namespache but different
        content models. The <m>definition script</m> is evaluated and
        defines the content model of the element. If the
        <m>namespace</m> argument is given, any <m>element</m> or
        <m>ref</m> references in the definition script not wrapped
        inside a <m>namespace</m> command are resolved in that
        namespace. If there is already a elementtype definition for
        the name/namespace combination the command raises
        error.</desc>
      </commanddef>

      <commanddef>
        <command><method>defpattern</method> <m>name</m> <m>?namespace?</m> <m>&lt;definition script></m></command>
        <desc>This method defines a (maybe complex) content particle
        with the <m>name</m> (optional in the namespace
        <m>namespace</m>) in the schema, to be referenced in other
        definition scripts with the definition command <m>ref</m>. The
        <m>definition script</m> is evaluated and defines the content
................................................................................
        element will be valid as root of a tree to validate.</desc>
      </commanddef>

      <commanddef>
        <command><method>define</method> <m>&lt;definition script></m></command>
        <desc>This method allows to define several elements or pattern
        or a whole schema with one call. All schema command methods so
        far (<m>prefixns</m>, <m>defelement</m>,
        <m>defelementtype</m>, <m>defpattern</m>, <m>deftext</m> and
        <m>start</m>) are allowed top level in the <m>definition
        script</m>. The <m>define</m> method itself isn't allowed
        recursively.</desc>
      </commanddef>
      
      <commanddef>
        <command><method>event</method> <m>(start|end|text)</m> <m>?event specific data?</m></command>
        <desc>This method allows to validate hierarchical data against
        the content constrains of the validation command.

................................................................................
        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,
        then the variable with that name is set to the empty string.</desc>
      </commanddef>

      <commanddef>
        <command><method>validatefile</method> <m>filename</m> <m>?objVar?</m></command>
        <desc>Returns true if the content of <m>filename</m> is valid
        or false otherwise. The given file is feeded as binary stream
        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 <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, then the variable with that name is set to
        the empty string.</desc>
      </commanddef>

      <commanddef>
        <command><method>domvalidate</method> <m>domNode</m> <m>?objVar?</m></command>
        <desc>Returns true if the first argument is a valid tree 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 dom tree is
        valid and the optional <m>objVar</m> argument is given, then