blob: aaef25d9ef23d4203ad81736bcc201d459c4fa2c [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__
12#include "tree.h"
13
Daniel Veillardb05deb71999-08-10 19:04:08 +000014/**
15 * an xmlValidCtxt is used for error reporting when validating
16 */
17
18typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
19typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
20
21typedef struct xmlValidCtxt {
22 void *userData; /* user specific data block */
23 xmlValidityErrorFunc error; /* the callback in case of errors */
24 xmlValidityWarningFunc warning; /* the callback in case of warning */
25} xmlValidCtxt, *xmlValidCtxtPtr;
26
27extern void xmlParserValidityError(void *ctx, const char *msg, ...);
28extern void xmlParserValidityWarning(void *ctx, const char *msg, ...);
29
Daniel Veillard3b9def11999-01-31 22:15:06 +000030/*
Daniel Veillard1e346af1999-02-22 10:33:01 +000031 * ALl notation declarations are stored in a table
32 * there is one table per DTD
33 */
34
35#define XML_MIN_NOTATION_TABLE 32
36
37typedef struct xmlNotationTable {
38 int nb_notations; /* number of notations stored */
39 int max_notations; /* maximum number of notations */
Daniel Veillardb05deb71999-08-10 19:04:08 +000040 xmlNotationPtr *table; /* the table of attributes */
Daniel Veillard1e346af1999-02-22 10:33:01 +000041} xmlNotationTable;
42typedef xmlNotationTable *xmlNotationTablePtr;
43
44/*
Daniel Veillard3b9def11999-01-31 22:15:06 +000045 * ALl element declarations are stored in a table
46 * there is one table per DTD
47 */
48
49#define XML_MIN_ELEMENT_TABLE 32
50
51typedef struct xmlElementTable {
52 int nb_elements; /* number of elements stored */
53 int max_elements; /* maximum number of elements */
Daniel Veillardb05deb71999-08-10 19:04:08 +000054 xmlElementPtr *table; /* the table of elements */
Daniel Veillard1e346af1999-02-22 10:33:01 +000055} xmlElementTable;
56typedef xmlElementTable *xmlElementTablePtr;
Daniel Veillard3b9def11999-01-31 22:15:06 +000057
Daniel Veillard1e346af1999-02-22 10:33:01 +000058/*
59 * ALl attribute declarations are stored in a table
60 * there is one table per DTD
61 */
62
63#define XML_MIN_ATTRIBUTE_TABLE 32
64
65typedef struct xmlAttributeTable {
66 int nb_attributes; /* number of attributes stored */
67 int max_attributes; /* maximum number of attributes */
Daniel Veillardb05deb71999-08-10 19:04:08 +000068 xmlAttributePtr *table; /* the table of attributes */
Daniel Veillard1e346af1999-02-22 10:33:01 +000069} xmlAttributeTable;
70typedef xmlAttributeTable *xmlAttributeTablePtr;
71
Daniel Veillard991e63d1999-08-15 23:32:28 +000072/*
73 * ALl IDs attributes are stored in a table
74 * there is one table per document
75 */
76
77#define XML_MIN_ID_TABLE 32
78
79typedef struct xmlIDTable {
80 int nb_ids; /* number of ids stored */
81 int max_ids; /* maximum number of ids */
82 xmlIDPtr *table; /* the table of ids */
83} xmlIDTable;
84typedef xmlIDTable *xmlIDTablePtr;
85
Daniel Veillard1e346af1999-02-22 10:33:01 +000086/* Notation */
Daniel Veillardb96e6431999-08-29 21:02:19 +000087xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
88 xmlDtdPtr dtd,
89 const CHAR *name,
90 const CHAR *PublicID,
91 const CHAR *SystemID);
Daniel Veillard1e346af1999-02-22 10:33:01 +000092xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
Daniel Veillardb96e6431999-08-29 21:02:19 +000093void xmlFreeNotationTable(xmlNotationTablePtr table);
94void xmlDumpNotationTable(xmlBufferPtr buf,
95 xmlNotationTablePtr table);
Daniel Veillard1e346af1999-02-22 10:33:01 +000096
97/* Element Content */
Daniel Veillardb96e6431999-08-29 21:02:19 +000098xmlElementContentPtr xmlNewElementContent (CHAR *name, int type);
Daniel Veillard1e346af1999-02-22 10:33:01 +000099xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000100void xmlFreeElementContent(xmlElementContentPtr cur);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000101
102/* Element */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000103xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt,
104 xmlDtdPtr dtd,
105 const CHAR *name,
106 int type,
107 xmlElementContentPtr content);
108xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
109void xmlFreeElementTable (xmlElementTablePtr table);
110void xmlDumpElementTable (xmlBufferPtr buf,
111 xmlElementTablePtr table);
Daniel Veillard3b9def11999-01-31 22:15:06 +0000112
Daniel Veillard1e346af1999-02-22 10:33:01 +0000113/* Enumeration */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000114xmlEnumerationPtr xmlCreateEnumeration (CHAR *name);
115void xmlFreeEnumeration (xmlEnumerationPtr cur);
116xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000117
118/* Attribute */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000119xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
120 xmlDtdPtr dtd,
121 const CHAR *elem,
122 const CHAR *name,
123 int type,
124 int def,
125 const CHAR *defaultValue,
126 xmlEnumerationPtr tree);
127xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
128void xmlFreeAttributeTable (xmlAttributeTablePtr table);
129void xmlDumpAttributeTable (xmlBufferPtr buf,
130 xmlAttributeTablePtr table);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000131
Daniel Veillard991e63d1999-08-15 23:32:28 +0000132/* IDs */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000133xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt,
134 xmlDocPtr doc,
135 const CHAR *value,
136 xmlAttrPtr attr);
137xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table);
138void xmlFreeIDTable (xmlIDTablePtr table);
139xmlAttrPtr xmlGetID (xmlDocPtr doc,
140 const CHAR *ID);
141int xmlIsID (xmlDocPtr doc,
142 xmlNodePtr elem,
143 xmlAttrPtr attr);
Daniel Veillard991e63d1999-08-15 23:32:28 +0000144
Daniel Veillardb05deb71999-08-10 19:04:08 +0000145/**
146 * The public function calls related to validity checking
147 */
148
Daniel Veillardb96e6431999-08-29 21:02:19 +0000149int xmlValidateRoot (xmlValidCtxtPtr ctxt,
150 xmlDocPtr doc);
151int xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
152 xmlDocPtr doc,
153 xmlElementPtr elem);
154int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
155 xmlDocPtr doc,
156 xmlAttributePtr attr);
157int xmlValidateAttributeValue(xmlAttributeType type,
158 const CHAR *value);
159int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
160 xmlDocPtr doc,
161 xmlNotationPtr nota);
162int xmlValidateDtd (xmlValidCtxtPtr ctxt,
163 xmlDocPtr doc,
164 xmlDtdPtr dtd);
165int xmlValidateDocument (xmlValidCtxtPtr ctxt,
166 xmlDocPtr doc);
167int xmlValidateElement (xmlValidCtxtPtr ctxt,
168 xmlDocPtr doc,
169 xmlNodePtr elem);
170int xmlValidateOneElement (xmlValidCtxtPtr ctxt,
171 xmlDocPtr doc,
172 xmlNodePtr elem);
173int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
174 xmlDocPtr doc,
175 xmlNodePtr elem,
176 xmlAttrPtr attr,
177 const CHAR *value);
178int xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
179 xmlDocPtr doc,
180 const CHAR *notationName);
181int xmlIsMixedElement (xmlDocPtr doc,
182 const CHAR *name);
183xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd,
184 const CHAR *elem,
185 const CHAR *name);
186xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd,
187 const CHAR *name);
188xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd,
189 const CHAR *name);
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000190#endif /* __XML_VALID_H__ */