1tnc(n)                                                                  tnc(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       tnc  -  tnc is an expat parser object extension, that validates the XML
9       stream against the document DTD while parsing.
10

SYNOPSIS

12       package require tdom
13       package require tnc
14
15       set parser [expat]
16
17       tnc $parser enable
18_________________________________________________________________
19

DESCRIPTION

21       tnc adds the C handler set "tnc" to a tcl expat parser obj.  This  han‐
22       dler  set is a simple DTD validator. If the validator detects a valida‐
23       tion error, it sets the interp result, signals error and stops parsing.
24       There  isn't  any  validation  error recovering. As a consequence, only
25       valid documents are completely parsed.
26
27       This handler set has only three methods:
28
29       tnc parserObj enable
30
31
32              Adds the tnc C handler set to a Tcl expat parser object.
33
34       tnc parserObj remove
35
36
37              Removes the tnc validatore from the parser parserObj  and  frees
38              all information, stored by it.
39
40       tnc parserObj getValidateCmd ?validateCmdName?
41
42
43              Returns  a  new  created validation command, if one is avaliable
44              from the parser command, otherwise it signals error. The name of
45              the  validation command is the validateCmdName, if this optional
46              argument was given, or a random choosen name. A validation  com‐
47              mand  is  avaliable  in a parser command, if the parser with tnc
48              enabled was previously used, to parse an  XML  document  with  a
49              valid  doctype  declaration, a valid external subset, if one was
50              given by the doctype declaration, and a valid  internal  subset.
51              The further document doesn't need to be valid, to make the vali‐
52              dation command avaliable. The validation command  can  only  get
53              received  one  time from the parser command. The created valida‐
54              tion command has this syntax:
55
56
57
58                     validationCmd method ?args?
59
60              The valid methods are:
61
62              validateDocument domDocument ?varName?
63                     Checks, if the given domDocument is valid against the DTD
64                     information   represented   by  the  validation  command.
65                     Returns 1, if the document ist valid, 0 otherwise. If the
66                     varName  argument is given, then the variable it names is
67                     set to the detected reason for the validation error or to
68                     the empty string in case of a valid document.
69
70              validateTree elementNode ?varName?
71                     Checks, if the given subtree with domNode as root element
72                     is a posible valid subtree of a  document  conforming  to
73                     the  DTD  information  represented by teh validation com‐
74                     mand. IDREF could not checked, while  validating  only  a
75                     subtree, but it is checked, that every known ID attribute
76                     in the subtree is unique. Returns 1, if  the  subtree  is
77                     OK,  0  otherwise. If the varName argument is given, then
78                     the variable it names is set to the detected  reason  for
79                     the  validation error or to the empty string in case of a
80                     valid subtree.
81
82              validateAttributes elementNode ?varName?
83                     Checks, if there is an element declaration for  the  name
84                     of  the elementNode in the DTD represented by the valida‐
85                     tion command and, if yes, if the attributes of  the  ele‐
86                     mentNode are conform to the ATTLIST declarations for that
87                     element in the DTD. Returns  1,  if  the  attributes  and
88                     there  value  types  are  OK, 0 otherwise. If the varName
89                     argument is given, then the variable it names is  set  to
90                     the  detected  reason  for the validation error or to the
91                     empty string in case the element  has  all  its  required
92                     attributes,  only  declared  attributes and the values of
93                     the attributes matches there type.
94
95              delete Deletes the validation command and frees the memory  used
96                     by it. Returns the empty string.
97

BUGS

99       The  validation  error reports could be much more informative and user-
100       friendly.
101
102       The validator doesn't detect ambiguous content models (see XML recomen‐
103       dation  Section  3.2.1  and  Appendix  E).  Most  Java  validators also
104       doesn't, but handle such content models right anyhow. Tnc does not;  if
105       your  DTD  has such ambiguous content models, tnc can not used to vali‐
106       date documents against such (not completely XML spec compliant) DTDs.
107
108       It isn't possible to validate XML documents  with  standalone="yes"  in
109       the XML Declaration
110
111       Violations  of  the  validity  constraints  Proper Group/PE Nesting and
112       Proper Conditional Section/PE Nesting are not detected. They could only
113       happen inside a invalid DTD, not in the content of a document.
114

KEYWORDS

116       Validation, DTD
117
118
119
120Tcl                                                                     tnc(n)
Impressum