tDOM

Check-in [39651ce911]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:If recovering from the error "text doesn't match constraint" pretent the text has matched so the not matched required text cp isn't reported again as missing text.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | keyspaces
Files: files | file ages | folders
SHA3-256: 39651ce91113ad9ab4e50e3a329eed7e17b434b87ea55e5046050c449733ab6c
User & Date: rolf 2019-05-30 01:02:22
Context
2019-05-30
22:38
Added simple keyref feature to keyspaces. check-in: 1f7b8a81c1 user: rolf tags: keyspaces
01:02
If recovering from the error "text doesn't match constraint" pretent the text has matched so the not matched required text cp isn't reported again as missing text. check-in: 39651ce911 user: rolf tags: keyspaces
2019-05-29
12:57
Starts to actually do something. Still some way to go. check-in: 6eb6891a1e user: rolf tags: keyspaces
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to generic/schema.c.

  1799   1799                       if (checkText (interp, candidate, text)) {
  1800   1800                           updateStack (se, cp, ac);
  1801   1801                           return 1;
  1802   1802                       }
  1803   1803                       if (!sdata->evalError) {
  1804   1804                           SetResult ("Invalid text content");
  1805   1805                       }
         1806  +                    updateStack (se, cp, ac);
  1806   1807                       return 0;
  1807   1808   
  1808   1809                   case SCHEMA_CTYPE_CHOICE:
  1809   1810                       if (candidate->flags & MIXED_CONTENT) {
  1810   1811                           updateStack (se, cp, ac);
  1811   1812                           return 1;
  1812   1813                       }

Changes to tests/schema.test.

  4576   4576           set rc [s validate $xml]
  4577   4577           lappend result $rc
  4578   4578       }
  4579   4579       s delete
  4580   4580       set result
  4581   4581   } {s UNKNOWN_ROOT_ELEMENT 1 s UNKNOWN_ROOT_ELEMENT 1 s UNKNOWN_ROOT_ELEMENT 1 s UNKNOWN_ROOT_ELEMENT 1}
  4582   4582   
         4583  +test schema-18.4 {reportcmd} {
         4584  +    tdom::schema s
         4585  +    s define {
         4586  +        defelement doc {
         4587  +            element items * {
         4588  +                element item * {
         4589  +                    attribute ref {integer}
         4590  +                }
         4591  +            }
         4592  +        }
         4593  +    }
         4594  +    s reportcmd schema-18
         4595  +    set result [list]
         4596  +    foreach xml {
         4597  +        {<doc><items><item ref="1"/><item ref="1"/></items><items><item ref="1"/><item ref="1"/></items></doc>}
         4598  +        {<doc><items><item ref="1"/><item ref="a"/></items><items><item ref="b"/><item ref="1"/></items></doc>}
         4599  +    } {
         4600  +        lappend result [s validate $xml]
         4601  +    }
         4602  +    s delete
         4603  +    set result
         4604  +} {1 s WRONG_ATTRIBUTE_VALUE s WRONG_ATTRIBUTE_VALUE 1}
         4605  +
         4606  +test schema-18.5 {reportcmd} {
         4607  +    tdom::schema s
         4608  +    s define {
         4609  +        defelement doc {
         4610  +            element items * {
         4611  +                element item * {
         4612  +                    text {minLength 2}
         4613  +                }
         4614  +            }
         4615  +        }
         4616  +    }
         4617  +    s reportcmd schema-18
         4618  +    set result [list]
         4619  +    foreach xml {
         4620  +        {<doc><items><item>1</item></items></doc>}
         4621  +        {<doc><items><item>1</item><item/></items></doc>}
         4622  +        {<doc><items><item>>12</item><item>ab</item></items></doc>}
         4623  +
         4624  +    } {
         4625  +        lappend result [s validate $xml]
         4626  +    }
         4627  +    s delete
         4628  +    set result
         4629  +} {s WRONG_VALUE 1 s WRONG_VALUE s MISSING_TEXT 1 1}
         4630  +
  4583   4631   proc validatedSAX {g xml {keepEmpties 1}} {
  4584   4632       set args [list -validateCmd $g]
  4585   4633       if {!$keepEmpties} {
  4586   4634           lappend args -ignorewhitespace 1
  4587   4635       }
  4588   4636       xml::parser p {*}$args
  4589   4637       set rc [catch {p parse $xml} errMsg]
................................................................................
  4638   4686       } {
  4639   4687           lappend result [s validate $xml]
  4640   4688       }
  4641   4689       s delete
  4642   4690       set result
  4643   4691   } {1 0 1 1 1 0}
  4644   4692   
         4693  +test schema-19.2 {keyspace} {
         4694  +    tdom::schema s
         4695  +    s define {
         4696  +        defelement doc {
         4697  +            element items * {
         4698  +                keyspace ref {
         4699  +                    element item * {
         4700  +                        attribute ref ? {
         4701  +                            key ref
         4702  +                        }
         4703  +                    }
         4704  +                }
         4705  +            }
         4706  +        }
         4707  +    }
         4708  +    s reportcmd schema-18
         4709  +    set result [list]
         4710  +    foreach xml {
         4711  +        {<doc><items><item ref="1"/><item ref="1"/></items><items><item ref="1"/><item ref="1"/></items></doc>}
         4712  +        {<doc><items><item ref="1"/><item ref="a"/></items><items><item ref="c"/><item ref="d"/></items></doc>}
         4713  +    } {
         4714  +        lappend result [s validate $xml]
         4715  +    }
         4716  +    s delete
         4717  +    set result
         4718  +} {s WRONG_ATTRIBUTE_VALUE s WRONG_ATTRIBUTE_VALUE 1 1}
         4719  +        
  4645   4720   test schema-20.1 {domunique} {
  4646   4721       set schema {
  4647   4722           prefixns {ns1 http://tdom.org/test}
  4648   4723           defelement doc {
  4649   4724               domunique ${::schema-20.1} @ref
  4650   4725           }
  4651   4726       }