blob: 8c016a93f2122832aaf8b0e1dd583489183ba0d2 [file] [log] [blame]
Daniel Veillard39a1f9a1999-01-17 19:11:59 +00001/*
2 * valid.h : interface to the DTD handling and the validity checking
3 *
4 * See Copyright for the status of this software.
5 *
6 * Daniel.Veillard@w3.org
7 */
8
9
10#ifndef __XML_VALID_H__
11#define __XML_VALID_H__
Daniel Veillardc26087b1999-08-30 11:23:51 +000012
13#ifdef __cplusplus
14extern "C" {
15#endif
16
Daniel Veillard39a1f9a1999-01-17 19:11:59 +000017#include "tree.h"
18
Daniel Veillardb05deb71999-08-10 19:04:08 +000019/**
20 * an xmlValidCtxt is used for error reporting when validating
21 */
22
23typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
24typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
25
26typedef struct xmlValidCtxt {
27 void *userData; /* user specific data block */
28 xmlValidityErrorFunc error; /* the callback in case of errors */
29 xmlValidityWarningFunc warning; /* the callback in case of warning */
30} xmlValidCtxt, *xmlValidCtxtPtr;
31
Daniel Veillard3b9def11999-01-31 22:15:06 +000032/*
Daniel Veillard1e346af1999-02-22 10:33:01 +000033 * ALl notation declarations are stored in a table
34 * there is one table per DTD
35 */
36
37#define XML_MIN_NOTATION_TABLE 32
38
39typedef struct xmlNotationTable {
40 int nb_notations; /* number of notations stored */
41 int max_notations; /* maximum number of notations */
Daniel Veillardb05deb71999-08-10 19:04:08 +000042 xmlNotationPtr *table; /* the table of attributes */
Daniel Veillard1e346af1999-02-22 10:33:01 +000043} xmlNotationTable;
44typedef xmlNotationTable *xmlNotationTablePtr;
45
46/*
Daniel Veillard3b9def11999-01-31 22:15:06 +000047 * ALl element declarations are stored in a table
48 * there is one table per DTD
49 */
50
51#define XML_MIN_ELEMENT_TABLE 32
52
53typedef struct xmlElementTable {
54 int nb_elements; /* number of elements stored */
55 int max_elements; /* maximum number of elements */
Daniel Veillardb05deb71999-08-10 19:04:08 +000056 xmlElementPtr *table; /* the table of elements */
Daniel Veillard1e346af1999-02-22 10:33:01 +000057} xmlElementTable;
58typedef xmlElementTable *xmlElementTablePtr;
Daniel Veillard3b9def11999-01-31 22:15:06 +000059
Daniel Veillard1e346af1999-02-22 10:33:01 +000060/*
61 * ALl attribute declarations are stored in a table
62 * there is one table per DTD
63 */
64
65#define XML_MIN_ATTRIBUTE_TABLE 32
66
67typedef struct xmlAttributeTable {
68 int nb_attributes; /* number of attributes stored */
69 int max_attributes; /* maximum number of attributes */
Daniel Veillardb05deb71999-08-10 19:04:08 +000070 xmlAttributePtr *table; /* the table of attributes */
Daniel Veillard1e346af1999-02-22 10:33:01 +000071} xmlAttributeTable;
72typedef xmlAttributeTable *xmlAttributeTablePtr;
73
Daniel Veillard991e63d1999-08-15 23:32:28 +000074/*
75 * ALl IDs attributes are stored in a table
76 * there is one table per document
77 */
78
79#define XML_MIN_ID_TABLE 32
80
81typedef struct xmlIDTable {
82 int nb_ids; /* number of ids stored */
83 int max_ids; /* maximum number of ids */
84 xmlIDPtr *table; /* the table of ids */
85} xmlIDTable;
86typedef xmlIDTable *xmlIDTablePtr;
87
Daniel Veillardc08a2c61999-09-08 21:35:25 +000088/*
89 * ALl Refs attributes are stored in a table
90 * there is one table per document
91 */
92
93#define XML_MIN_REF_TABLE 32
94
95typedef struct xmlRefTable {
96 int nb_refs; /* number of refs stored */
97 int max_refs; /* maximum number of refs */
98 xmlRefPtr *table; /* the table of refs */
99} xmlRefTable;
100typedef xmlRefTable *xmlRefTablePtr;
101
Daniel Veillard1e346af1999-02-22 10:33:01 +0000102/* Notation */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000103xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
104 xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000105 const xmlChar *name,
106 const xmlChar *PublicID,
107 const xmlChar *SystemID);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000108xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000109void xmlFreeNotationTable(xmlNotationTablePtr table);
110void xmlDumpNotationTable(xmlBufferPtr buf,
111 xmlNotationTablePtr table);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000112
113/* Element Content */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000114xmlElementContentPtr xmlNewElementContent (xmlChar *name,
Daniel Veillardc26087b1999-08-30 11:23:51 +0000115 xmlElementContentType type);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000116xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000117void xmlFreeElementContent(xmlElementContentPtr cur);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000118
119/* Element */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000120xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt,
121 xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000122 const xmlChar *name,
Daniel Veillardc26087b1999-08-30 11:23:51 +0000123 xmlElementContentType type,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000124 xmlElementContentPtr content);
125xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
126void xmlFreeElementTable (xmlElementTablePtr table);
127void xmlDumpElementTable (xmlBufferPtr buf,
128 xmlElementTablePtr table);
Daniel Veillard3b9def11999-01-31 22:15:06 +0000129
Daniel Veillard1e346af1999-02-22 10:33:01 +0000130/* Enumeration */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000131xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000132void xmlFreeEnumeration (xmlEnumerationPtr cur);
133xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000134
135/* Attribute */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000136xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
137 xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000138 const xmlChar *elem,
139 const xmlChar *name,
Daniel Veillardc26087b1999-08-30 11:23:51 +0000140 xmlAttributeType type,
141 xmlAttributeDefault def,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000142 const xmlChar *defaultValue,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000143 xmlEnumerationPtr tree);
144xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
145void xmlFreeAttributeTable (xmlAttributeTablePtr table);
146void xmlDumpAttributeTable (xmlBufferPtr buf,
147 xmlAttributeTablePtr table);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000148
Daniel Veillard991e63d1999-08-15 23:32:28 +0000149/* IDs */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000150xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt,
151 xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000152 const xmlChar *value,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000153 xmlAttrPtr attr);
154xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table);
155void xmlFreeIDTable (xmlIDTablePtr table);
156xmlAttrPtr xmlGetID (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000157 const xmlChar *ID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000158int xmlIsID (xmlDocPtr doc,
159 xmlNodePtr elem,
160 xmlAttrPtr attr);
Daniel Veillard991e63d1999-08-15 23:32:28 +0000161
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000162/* IDREFs */
163xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt,
164 xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000165 const xmlChar *value,
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000166 xmlAttrPtr attr);
167xmlRefTablePtr xmlCopyRefTable (xmlRefTablePtr table);
168void xmlFreeRefTable (xmlRefTablePtr table);
169int xmlIsRef (xmlDocPtr doc,
170 xmlNodePtr elem,
171 xmlAttrPtr attr);
172
Daniel Veillardb05deb71999-08-10 19:04:08 +0000173/**
174 * The public function calls related to validity checking
175 */
176
Daniel Veillardb96e6431999-08-29 21:02:19 +0000177int xmlValidateRoot (xmlValidCtxtPtr ctxt,
178 xmlDocPtr doc);
179int xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
180 xmlDocPtr doc,
181 xmlElementPtr elem);
182int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
183 xmlDocPtr doc,
184 xmlAttributePtr attr);
185int xmlValidateAttributeValue(xmlAttributeType type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000186 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000187int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
188 xmlDocPtr doc,
189 xmlNotationPtr nota);
190int xmlValidateDtd (xmlValidCtxtPtr ctxt,
191 xmlDocPtr doc,
192 xmlDtdPtr dtd);
193int xmlValidateDocument (xmlValidCtxtPtr ctxt,
194 xmlDocPtr doc);
195int xmlValidateElement (xmlValidCtxtPtr ctxt,
196 xmlDocPtr doc,
197 xmlNodePtr elem);
198int xmlValidateOneElement (xmlValidCtxtPtr ctxt,
199 xmlDocPtr doc,
200 xmlNodePtr elem);
201int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
202 xmlDocPtr doc,
203 xmlNodePtr elem,
204 xmlAttrPtr attr,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000205 const xmlChar *value);
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000206int xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
207 xmlDocPtr doc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000208int xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
209 xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000210 const xmlChar *notationName);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000211int xmlIsMixedElement (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000212 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000213xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000214 const xmlChar *elem,
215 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000216xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000217 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000218xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000219 const xmlChar *name);
Daniel Veillardc26087b1999-08-30 11:23:51 +0000220
Daniel Veillard7c1206f1999-10-14 09:10:25 +0000221int xmlValidGetValidElements(xmlNode *prev,
222 xmlNode *next,
223 const xmlChar **list,
224 int max);
225int xmlValidGetPotentialChildren(xmlElementContent *ctree,
226 const xmlChar **list,
227 int *len,
228 int max);
Daniel Veillardc26087b1999-08-30 11:23:51 +0000229#ifdef __cplusplus
230}
231#endif
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000232#endif /* __XML_VALID_H__ */