tDOM

Check-in [7a6bb5d975]
Login

Check-in [7a6bb5d975]

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

Overview
Comment:Save work.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | recover-doc-wip
Files: files | file ages | folders
SHA3-256: 7a6bb5d975b9ef2610e5bf70cf1eff3d180e514c3390648e569f963a27955a0f
User & Date: rolf 2020-01-25 14:43:02.593
Context
2020-01-27
23:42
Save work. check-in: 70eb60b0b9 user: rolf tags: recover-doc-wip
2020-01-25
14:43
Save work. check-in: 7a6bb5d975 user: rolf tags: recover-doc-wip
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
Changes
Unified Diff Ignore Whitespace Patch
Changes to doc/schema.xml.
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
            <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>&lt;XML string></m> <m>?objVar?</m></command>
        <desc>Returns true if the <m>&lt;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,







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







155
156
157
158
159
160
161





























162
163
164
165
166
167
168
            <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>&lt;XML string></m> <m>?objVar?</m></command>
        <desc>Returns true if the <m>&lt;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,
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
                  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.</desc>
              </optdef>
              <optdef>
                  <optname>nrForwardDefinitions</optname>
                  <desc>Returns the at least used once referenced
                  element and ref particles that aren't defined so far
                  (summed together).</desc>
              </optdef>
              <optdef>
                  <optname>definedElements</optname>
                  <desc>Returns in no particular order the defined
                  elements in the grammer as list. If an element is
                  namespaced its list entry will be itself a list with







|
|







262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
                  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.</desc>
              </optdef>
              <optdef>
                  <optname>nrForwardDefinitions</optname>
                  <desc>Returns how much element, elementtype and ref
                  pattern are referenced that aren't defined so far
                  (summed together).</desc>
              </optdef>
              <optdef>
                  <optname>definedElements</optname>
                  <desc>Returns in no particular order the defined
                  elements in the grammer as list. If an element is
                  namespaced its list entry will be itself a list with
355
356
357
358
359
360
361

362
363

364
365
366
367

368
369

370


371
372
373




























374
375
376
377
378
379
380
                  arguments the command returns detail information
                  depending on current action.
                  <dl>
                      <dt>name</dt><dd>Return the name of the element
                      that has to match in case of
                      MATCH_ELEMENT_START. Return the name of the
                      closed element in case of MATCH_ELEMENT_END.

                      Return the name of the parent element in case of
                      MATCH_TEXT.</dd>

                      <dt>namespace</dt><dd>Return the namespace of
                      the element that has to match in case of
                      MATCH_ELEMENT_START. Return the namespace of the
                      closed element in case of MATCH_ELEMENT_END.

                      Return the namespace of the parent element in
                      case of MATCH_TEXT.</dd>

                      <dt>text</dt><dd></dd>


                  </dl>
                  </desc>
              </optdef>




























          </optlist>
          </desc>
      </commanddef>
      
      <commanddef>
        <command><method>reset</method></command>
        <desc>This method resets the validation command into state







>
|
|
>




>
|
|
>
|
>
>



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







326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
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
373
374
375
376
377
378
379
380
381
382
383
384
385
                  arguments the command returns detail information
                  depending on current action.
                  <dl>
                      <dt>name</dt><dd>Return the name of the element
                      that has to match in case of
                      MATCH_ELEMENT_START. Return the name of the
                      closed element in case of MATCH_ELEMENT_END.
                      Returns the name of the attribute in case of
                      MATCH_ATTRIBUTE_TEXT. Return the name of the
                      parent element in case of MATCH_TEXT.</dd>
                      
                      <dt>namespace</dt><dd>Return the namespace of
                      the element that has to match in case of
                      MATCH_ELEMENT_START. Return the namespace of the
                      closed element in case of MATCH_ELEMENT_END.
                      Returns the namespace of the attribute in case
                      of MATCH_ATTRIBUTE_TEXT. Return the namespace of
                      the parent element in case of MATCH_TEXT.</dd>
                      
                      <dt>text</dt><dd>Return the text in case of
                      MATCH_TEXTReturns the value of the attribute in
                      case of MATCH_ATTRIBUTE_TEXT.</dd>
                  </dl>
                  </desc>
              </optdef>
              <optdef>
                  <optname>stack top|inside|associated</optname>
                  <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>
              </optdef>
          </optlist>
          </desc>
      </commanddef>
      
      <commanddef>
        <command><method>reset</method></command>
        <desc>This method resets the validation command into state
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
    constraints.</p>

    <commandlist>
        <commanddef>
            <command><cmd>keyspace</cmd> <m>&lt;names list></m> <m>&lt;constraint script></m></command>
            <desc>Any number of keyspaces are possible. A keyspace is
            either active or not. An inside a <m>constraint
            script></m> called keyspace with the same name does
            nothing.</desc>
        </commanddef>
    </commandlist>

    <p>This text constraint commands work with keyspaces:</p>

    <commandlist>







|







919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
    constraints.</p>

    <commandlist>
        <commanddef>
            <command><cmd>keyspace</cmd> <m>&lt;names list></m> <m>&lt;constraint script></m></command>
            <desc>Any number of keyspaces are possible. A keyspace is
            either active or not. An inside a <m>constraint
            script</m> called keyspace with the same name does
            nothing.</desc>
        </commanddef>
    </commandlist>

    <p>This text constraint commands work with keyspaces:</p>

    <commandlist>
Changes to generic/schema.c.
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
        sdata->vaction = MATCH_ATTRIBUTE_TEXT;
        break;
    }
    sdata->currentEvals++;
    rc = Tcl_EvalObjEx (interp, cmdPtr,
                        TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
    sdata->currentEvals--;
    sdata->vaction = MATCH_GLOBAL;
    sdata->vname = NULL;
    sdata->vns = NULL;
    sdata->vtext = NULL;
    Tcl_DecrRefCount (cmdPtr);
    if (rc != TCL_OK) {
        sdata->evalError = 1;
        return 0;







|







1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
        sdata->vaction = MATCH_ATTRIBUTE_TEXT;
        break;
    }
    sdata->currentEvals++;
    rc = Tcl_EvalObjEx (interp, cmdPtr,
                        TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
    sdata->currentEvals--;
    sdata->vaction = 0;
    sdata->vname = NULL;
    sdata->vns = NULL;
    sdata->vtext = NULL;
    Tcl_DecrRefCount (cmdPtr);
    if (rc != TCL_OK) {
        sdata->evalError = 1;
        return 0;
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
    result = Tcl_EvalObjEx (interp, objv[2], TCL_EVAL_DIRECT);
    sdata->currentEvals--;
    sdata->currentNamespace = currentNamespace;
    return result;
}

static int
TextPatternObjCmd (
    ClientData clientData,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[]
    )
{
    SchemaData *sdata = GETASI;







|







5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
    result = Tcl_EvalObjEx (interp, objv[2], TCL_EVAL_DIRECT);
    sdata->currentEvals--;
    sdata->currentNamespace = currentNamespace;
    return result;
}

static int
TextPatternObjCmd  (
    ClientData clientData,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[]
    )
{
    SchemaData *sdata = GETASI;
Changes to tests/schema.test.
6800
6801
6802
6803
6804
6805
6806

































6807
6808
6809
6810
6811
6812
6813
        <header><latestloc/><prevlocs/></header>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {{reportcmd called} 1 1 1 1 1}


































proc validatedSAX {g xml {keepEmpties 1}} {
    set args [list -validateCmd $g]
    if {!$keepEmpties} {
        lappend args -ignorewhitespace 1
    }
    xml::parser p {*}$args







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







6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
        <header><latestloc/><prevlocs/></header>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {{reportcmd called} 1 1 1 1 1}

# proc schema-18.14 {scmd args} {
#     lappend ::result [$scmd info vaction]
#     lappend ::result [$scmd info vaction name]
#     lappend ::result [$scmd info vaction namespace]
#     lappend ::result [$scmd info vaction text]
# }
# test schema-18.14 {info vaction in reportcmd} {
#     tdom::schema s
#     s reportcmd schema-18.14
#     s define {
#         defelement doc {
#             element e + {
#                 attribute attr1 {
#                     fixed on
#                 }
#                 text {
#                     minLength 4
#                 }
#             }
#         }
#     }
#     set result [list]
#     foreach xml {
#         <doc/>
#         <doc><e>123</e></doc>
#         {<doc><e attr1="off">1234</e></doc>}
#     } {
#         lappend result [s validate $xml]
#     }
#     s delete
#     set result
# } {}

proc validatedSAX {g xml {keepEmpties 1}} {
    set args [list -validateCmd $g]
    if {!$keepEmpties} {
        lappend args -ignorewhitespace 1
    }
    xml::parser p {*}$args