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

Overview
Comment:Added text constraint command hexBinary (similar to the xsd type hexBinary).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | schema
Files: files | file ages | folders
SHA3-256: ea199fedb785892fe7bb8865e18bc0c576a0a8f0c88c01afbe8d77e02ac1ead0
User & Date: rolf 2019-11-29 16:42:35
Context
2019-11-30
00:07
Implemented the text constraint commands unsignedByte, unsignedShort, unsignedInt and unsignedLong, along the xsd counterparts. check-in: 051ae451a2 user: rolf tags: schema
2019-11-29
16:42
Added text constraint command hexBinary (similar to the xsd type hexBinary). check-in: ea199fedb7 user: rolf tags: schema
00:29
Added the xsd data types negativeInteger, nonNegativeInteger, nonPositiveInteger and positiveInteger. check-in: d3fc207059 user: rolf tags: schema
Changes

Changes to doc/schema.xml.

767
768
769
770
771
772
773







774
775
776
777
778
779
780
        references within the document to one ID are possible.</desc>
      </commanddef>
      <commanddef>
        <command><cmd>base64</cmd></command>
        <desc>This text constraint match if text is valid according to
        RFC 4648.</desc>
      </commanddef>







    </commandlist>
  </section>

  <section>
    <title>Local key constraints</title>

    <p>Document wide uniqueness and foreign key constraints are







>
>
>
>
>
>
>







767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
        references within the document to one ID are possible.</desc>
      </commanddef>
      <commanddef>
        <command><cmd>base64</cmd></command>
        <desc>This text constraint match if text is valid according to
        RFC 4648.</desc>
      </commanddef>
      <commanddef>
        <command><cmd>hexBinary</cmd></command>
        <desc>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.</desc>
      </commanddef>
    </commandlist>
  </section>

  <section>
    <title>Local key constraints</title>

    <p>Document wide uniqueness and foreign key constraints are

Changes to generic/schema.c.

6599
6600
6601
6602
6603
6604
6605









































6606
6607
6608
6609
6610
6611
6612
....
6725
6726
6727
6728
6729
6730
6731


6732
6733
6734
6735
    CHECK_TI
    CHECK_TOPLEVEL
    checkNrArgs (1,1,"No arguments expected");
    ADD_CONSTRAINT (sdata, sc)
    sc->constraint = qnameImpl;
    return TCL_OK;
}










































void
tDOM_SchemaInit (
    Tcl_Interp *interp
    )
{
    Tcl_CreateObjCommand (interp, "tdom::schema", tDOM_SchemaObjCmd,
................................................................................
                          keyrefTCObjCmd, NULL, NULL);
    Tcl_CreateObjCommand (interp,"tdom::schema::text::name",
                          nameTCObjCmd, NULL, NULL);
    Tcl_CreateObjCommand (interp,"tdom::schema::text::ncname",
                          ncnameTCObjCmd, NULL, NULL);
    Tcl_CreateObjCommand (interp,"tdom::schema::text::qname",
                          qnameTCObjCmd, NULL, NULL);


}


#endif  /* #ifndef TDOM_NO_SCHEMA */







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







 







>
>




6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
....
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
    CHECK_TI
    CHECK_TOPLEVEL
    checkNrArgs (1,1,"No arguments expected");
    ADD_CONSTRAINT (sdata, sc)
    sc->constraint = qnameImpl;
    return TCL_OK;
}

static int
hexBinaryImpl (
    Tcl_Interp *interp,
    void *constraintData,
    char *text
    )
{
    int count = 0;

    if (*text == 0) return 0;
    while (*text) {
        if ((*text >= '0' && *text <= '9')
            || (*text >= 'A' && *text <= 'F')
            || (*text >= 'a' && *text <= 'f')) {
            text++;
            count++;
        } else return 0;
    }
    if (count % 2 == 0) return 1;
    return 0;
}

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

    CHECK_TI
    CHECK_TOPLEVEL
    checkNrArgs (1,1,"No arguments expected");
    ADD_CONSTRAINT (sdata, sc)
    sc->constraint = hexBinaryImpl;
    return TCL_OK;
}

void
tDOM_SchemaInit (
    Tcl_Interp *interp
    )
{
    Tcl_CreateObjCommand (interp, "tdom::schema", tDOM_SchemaObjCmd,
................................................................................
                          keyrefTCObjCmd, NULL, NULL);
    Tcl_CreateObjCommand (interp,"tdom::schema::text::name",
                          nameTCObjCmd, NULL, NULL);
    Tcl_CreateObjCommand (interp,"tdom::schema::text::ncname",
                          ncnameTCObjCmd, NULL, NULL);
    Tcl_CreateObjCommand (interp,"tdom::schema::text::qname",
                          qnameTCObjCmd, NULL, NULL);
    Tcl_CreateObjCommand (interp,"tdom::schema::text::hexBinary",
                          hexBinaryTCObjCmd, NULL, NULL);
}


#endif  /* #ifndef TDOM_NO_SCHEMA */

Changes to tests/schema.test.

4778
4779
4780
4781
4782
4783
4784


























4785
4786
4787
4788
4789
4790
4791
        {<doc> </doc>}
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0}



























test schema-15.1 {constraint cmd tcl} {
    tdom::schema s
    s define {
        defelement a {
            tcl append ::schema-15.1
            element b







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







4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
        {<doc> </doc>}
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0}

test schema-14.36 {text: hexBinary} {
    tdom::schema s
    s defelement doc {
        text {hexBinary}
    }
    set result [list]
    foreach xml {
        <doc/>
        <doc>5782</doc>
        <doc>3ABCDEF0</doc>
        <doc>+2</doc>
        <doc>2</doc>
        <doc>abcd</doc>
        <doc>abcde</doc>
        <doc>abcdef</doc>
        <doc>abcdefg</doc>
        {<doc> a0123b</doc>}
        {<doc>a0123b </doc>}
        <doc>a0123b</doc>
    } {
        lappend result [s validate $xml]
    }
    s delete
    set result
} {0 1 1 0 0 1 0 1 0 0 0 1}

test schema-15.1 {constraint cmd tcl} {
    tdom::schema s
    s define {
        defelement a {
            tcl append ::schema-15.1
            element b