blob: 30a2a32fbd22f895d5011172d9baaa17ed30f617 [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
32extern void xmlParserValidityError(void *ctx, const char *msg, ...);
33extern void xmlParserValidityWarning(void *ctx, const char *msg, ...);
34
Daniel Veillard3b9def11999-01-31 22:15:06 +000035/*
Daniel Veillard1e346af1999-02-22 10:33:01 +000036 * ALl notation declarations are stored in a table
37 * there is one table per DTD
38 */
39
40#define XML_MIN_NOTATION_TABLE 32
41
42typedef struct xmlNotationTable {
43 int nb_notations; /* number of notations stored */
44 int max_notations; /* maximum number of notations */
Daniel Veillardb05deb71999-08-10 19:04:08 +000045 xmlNotationPtr *table; /* the table of attributes */
Daniel Veillard1e346af1999-02-22 10:33:01 +000046} xmlNotationTable;
47typedef xmlNotationTable *xmlNotationTablePtr;
48
49/*
Daniel Veillard3b9def11999-01-31 22:15:06 +000050 * ALl element declarations are stored in a table
51 * there is one table per DTD
52 */
53
54#define XML_MIN_ELEMENT_TABLE 32
55
56typedef struct xmlElementTable {
57 int nb_elements; /* number of elements stored */
58 int max_elements; /* maximum number of elements */
Daniel Veillardb05deb71999-08-10 19:04:08 +000059 xmlElementPtr *table; /* the table of elements */
Daniel Veillard1e346af1999-02-22 10:33:01 +000060} xmlElementTable;
61typedef xmlElementTable *xmlElementTablePtr;
Daniel Veillard3b9def11999-01-31 22:15:06 +000062
Daniel Veillard1e346af1999-02-22 10:33:01 +000063/*
64 * ALl attribute declarations are stored in a table
65 * there is one table per DTD
66 */
67
68#define XML_MIN_ATTRIBUTE_TABLE 32
69
70typedef struct xmlAttributeTable {
71 int nb_attributes; /* number of attributes stored */
72 int max_attributes; /* maximum number of attributes */
Daniel Veillardb05deb71999-08-10 19:04:08 +000073 xmlAttributePtr *table; /* the table of attributes */
Daniel Veillard1e346af1999-02-22 10:33:01 +000074} xmlAttributeTable;
75typedef xmlAttributeTable *xmlAttributeTablePtr;
76
Daniel Veillard991e63d1999-08-15 23:32:28 +000077/*
78 * ALl IDs attributes are stored in a table
79 * there is one table per document
80 */
81
82#define XML_MIN_ID_TABLE 32
83
84typedef struct xmlIDTable {
85 int nb_ids; /* number of ids stored */
86 int max_ids; /* maximum number of ids */
87 xmlIDPtr *table; /* the table of ids */
88} xmlIDTable;
89typedef xmlIDTable *xmlIDTablePtr;
90
Daniel Veillardc08a2c61999-09-08 21:35:25 +000091/*
92 * ALl Refs attributes are stored in a table
93 * there is one table per document
94 */
95
96#define XML_MIN_REF_TABLE 32
97
98typedef struct xmlRefTable {
99 int nb_refs; /* number of refs stored */
100 int max_refs; /* maximum number of refs */
101 xmlRefPtr *table; /* the table of refs */
102} xmlRefTable;
103typedef xmlRefTable *xmlRefTablePtr;
104
Daniel Veillard1e346af1999-02-22 10:33:01 +0000105/* Notation */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000106xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
107 xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000108 const xmlChar *name,
109 const xmlChar *PublicID,
110 const xmlChar *SystemID);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000111xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000112void xmlFreeNotationTable(xmlNotationTablePtr table);
113void xmlDumpNotationTable(xmlBufferPtr buf,
114 xmlNotationTablePtr table);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000115
116/* Element Content */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000117xmlElementContentPtr xmlNewElementContent (xmlChar *name,
Daniel Veillardc26087b1999-08-30 11:23:51 +0000118 xmlElementContentType type);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000119xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000120void xmlFreeElementContent(xmlElementContentPtr cur);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000121
122/* Element */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000123xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt,
124 xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000125 const xmlChar *name,
Daniel Veillardc26087b1999-08-30 11:23:51 +0000126 xmlElementContentType type,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000127 xmlElementContentPtr content);
128xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
129void xmlFreeElementTable (xmlElementTablePtr table);
130void xmlDumpElementTable (xmlBufferPtr buf,
131 xmlElementTablePtr table);
Daniel Veillard3b9def11999-01-31 22:15:06 +0000132
Daniel Veillard1e346af1999-02-22 10:33:01 +0000133/* Enumeration */
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000134xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000135void xmlFreeEnumeration (xmlEnumerationPtr cur);
136xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000137
138/* Attribute */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000139xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
140 xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000141 const xmlChar *elem,
142 const xmlChar *name,
Daniel Veillardc26087b1999-08-30 11:23:51 +0000143 xmlAttributeType type,
144 xmlAttributeDefault def,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000145 const xmlChar *defaultValue,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000146 xmlEnumerationPtr tree);
147xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
148void xmlFreeAttributeTable (xmlAttributeTablePtr table);
149void xmlDumpAttributeTable (xmlBufferPtr buf,
150 xmlAttributeTablePtr table);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000151
Daniel Veillard991e63d1999-08-15 23:32:28 +0000152/* IDs */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000153xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt,
154 xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000155 const xmlChar *value,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000156 xmlAttrPtr attr);
157xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table);
158void xmlFreeIDTable (xmlIDTablePtr table);
159xmlAttrPtr xmlGetID (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000160 const xmlChar *ID);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000161int xmlIsID (xmlDocPtr doc,
162 xmlNodePtr elem,
163 xmlAttrPtr attr);
Daniel Veillard991e63d1999-08-15 23:32:28 +0000164
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000165/* IDREFs */
166xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt,
167 xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000168 const xmlChar *value,
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000169 xmlAttrPtr attr);
170xmlRefTablePtr xmlCopyRefTable (xmlRefTablePtr table);
171void xmlFreeRefTable (xmlRefTablePtr table);
172int xmlIsRef (xmlDocPtr doc,
173 xmlNodePtr elem,
174 xmlAttrPtr attr);
175
Daniel Veillardb05deb71999-08-10 19:04:08 +0000176/**
177 * The public function calls related to validity checking
178 */
179
Daniel Veillardb96e6431999-08-29 21:02:19 +0000180int xmlValidateRoot (xmlValidCtxtPtr ctxt,
181 xmlDocPtr doc);
182int xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
183 xmlDocPtr doc,
184 xmlElementPtr elem);
185int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
186 xmlDocPtr doc,
187 xmlAttributePtr attr);
188int xmlValidateAttributeValue(xmlAttributeType type,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000189 const xmlChar *value);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000190int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
191 xmlDocPtr doc,
192 xmlNotationPtr nota);
193int xmlValidateDtd (xmlValidCtxtPtr ctxt,
194 xmlDocPtr doc,
195 xmlDtdPtr dtd);
196int xmlValidateDocument (xmlValidCtxtPtr ctxt,
197 xmlDocPtr doc);
198int xmlValidateElement (xmlValidCtxtPtr ctxt,
199 xmlDocPtr doc,
200 xmlNodePtr elem);
201int xmlValidateOneElement (xmlValidCtxtPtr ctxt,
202 xmlDocPtr doc,
203 xmlNodePtr elem);
204int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
205 xmlDocPtr doc,
206 xmlNodePtr elem,
207 xmlAttrPtr attr,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000208 const xmlChar *value);
Daniel Veillardc08a2c61999-09-08 21:35:25 +0000209int xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
210 xmlDocPtr doc);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000211int xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
212 xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000213 const xmlChar *notationName);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000214int xmlIsMixedElement (xmlDocPtr doc,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000215 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000216xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000217 const xmlChar *elem,
218 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000219xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000220 const xmlChar *name);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000221xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd,
Daniel Veillarddd6b3671999-09-23 22:19:22 +0000222 const xmlChar *name);
Daniel Veillardc26087b1999-08-30 11:23:51 +0000223
224#ifdef __cplusplus
225}
226#endif
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000227#endif /* __XML_VALID_H__ */