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

Overview
Comment:The attribute und nsattribute commands are only supported toplevel in the definition scripts of the defelement method and the element command.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: b3b2ce77f0192b61815edfe0a0da0b9b9528d1e398b89f539859af76e4517486
User & Date: rolf 2019-11-18 22:37:09
Context
2019-11-18
22:42
Removed slipped throu debuging instrumentalization. check-in: 22b17ef648 user: rolf tags: schema
22:37
The attribute und nsattribute commands are only supported toplevel in the definition scripts of the defelement method and the element command. check-in: b3b2ce77f0 user: rolf tags: schema
2019-11-16
13:09
A few spell fixes. check-in: 7726a079e1 user: rolf tags: schema
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/schema.xml.

409
410
411
412
413
414
415
416

417
418
419
420
421
422
423
        <m>name</m> 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.</desc>

      </commanddef>

      <commanddef>
        <command><method>nsattribute</method> <m>name</m> <m>namespace</m> <m>?quant?</m> <m>(?&lt;constraint script>|"type" typename?)</m></command>
        <desc>This command does the same as the command
        <m>attribute</m>, just for the attribute <m>name</m> in the
        namespace <m>namespace</m>.</desc>







|
>







409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
        <m>name</m> 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.</desc>
      </commanddef>

      <commanddef>
        <command><method>nsattribute</method> <m>name</m> <m>namespace</m> <m>?quant?</m> <m>(?&lt;constraint script>|"type" typename?)</m></command>
        <desc>This command does the same as the command
        <m>attribute</m>, just for the attribute <m>name</m> in the
        namespace <m>namespace</m>.</desc>

Changes to generic/schema.c.

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
....
4589
4590
4591
4592
4593
4594
4595





4596
4597
4598
4599
4600
4601
4602

#include <tdom.h>
#include <tcldom.h>
#include <domxpath.h>
#include <schema.h>

/* #define DEBUG */
/* #define DDEBUG */
/*----------------------------------------------------------------------------
|   Debug Macros
|
\---------------------------------------------------------------------------*/
#ifdef DEBUG
# define DBG(x) x
#else
................................................................................
    Tcl_Obj *nsObj, *nameObj;
    Tcl_HashEntry *h;
    SchemaCP *type;

    CHECK_SI
    CHECK_TOPLEVEL






    if (clientData) {
        checkNrArgs (3,6,"Expected:"
                     "  name namespace"
                     " | name namespace attquant"
                     " | name namespace ?attquant? <constraint script>"
                     " | name namespace ?attquant? \"type\" typename");
        nsObj = objv[2];







|







 







>
>
>
>
>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
....
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607

#include <tdom.h>
#include <tcldom.h>
#include <domxpath.h>
#include <schema.h>

/* #define DEBUG */
#define DDEBUG
/*----------------------------------------------------------------------------
|   Debug Macros
|
\---------------------------------------------------------------------------*/
#ifdef DEBUG
# define DBG(x) x
#else
................................................................................
    Tcl_Obj *nsObj, *nameObj;
    Tcl_HashEntry *h;
    SchemaCP *type;

    CHECK_SI
    CHECK_TOPLEVEL

        serializeCP (sdata->cp);
    if (sdata->cp->type != SCHEMA_CTYPE_NAME) {
        SetResult ("The commands attribute and nsattribute are only allowed toplevel in element definition scripts");
        return TCL_ERROR;
    }
    if (clientData) {
        checkNrArgs (3,6,"Expected:"
                     "  name namespace"
                     " | name namespace attquant"
                     " | name namespace ?attquant? <constraint script>"
                     " | name namespace ?attquant? \"type\" typename");
        nsObj = objv[2];

Changes to tests/schema.test.

2954
2955
2956
2957
2958
2959
2960


















2961
2962
2963
2964
2965
2966
2967
        lappend result [catch {set doc [dom parse -validateCmd s $xml]} errMsg]
        lappend result $errMsg
        s reset
    }
    s delete
    set result
} {1 {Missing mandatory attribute(s): http://www.w3.org/XML/1998/namespace:lang, referenced at line 1 character 19} 1 {Missing mandatory attribute(s): foo, referenced at line 1 character 23} 1 {Unknown attribute "unknown", referenced at line 1 character 24} 1 {Missing mandatory attribute(s): foo http://www.w3.org/XML/1998/namespace:lang, referenced at line 1 character 9}}



















test schema-12.1 {domvalidate} {
    tdom::schema s 
    s define {
        defelement addressBook {
            element card *
        }







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







2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
        lappend result [catch {set doc [dom parse -validateCmd s $xml]} errMsg]
        lappend result $errMsg
        s reset
    }
    s delete
    set result
} {1 {Missing mandatory attribute(s): http://www.w3.org/XML/1998/namespace:lang, referenced at line 1 character 19} 1 {Missing mandatory attribute(s): foo, referenced at line 1 character 23} 1 {Unknown attribute "unknown", referenced at line 1 character 24} 1 {Missing mandatory attribute(s): foo http://www.w3.org/XML/1998/namespace:lang, referenced at line 1 character 9}}

test schema-11.7 {attribute} {
    set defs {
        {defelement doc {attribute foo}}
        {defelement doc {group {attribute foo}}}
        {defpattern some {attribute foo}}
        {defelement doc {element {attribute foo}}}
    }
    set result [list]
    foreach def $defs {
        puts $def
        tdom::schema create s
        lappend result [catch {s define $def} errMsg]
        puts $errMsg
        s delete
    }
    set result
} {0 1 1 0}

test schema-12.1 {domvalidate} {
    tdom::schema s 
    s define {
        defelement addressBook {
            element card *
        }