blob: 37b4f999921a9efa3b5e31abc51ab5d1e6d525fb [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 Veillard1e346af1999-02-22 10:33:01 +000091/* Notation */
Daniel Veillardb96e6431999-08-29 21:02:19 +000092xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
93 xmlDtdPtr dtd,
94 const CHAR *name,
95 const CHAR *PublicID,
96 const CHAR *SystemID);
Daniel Veillard1e346af1999-02-22 10:33:01 +000097xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
Daniel Veillardb96e6431999-08-29 21:02:19 +000098void xmlFreeNotationTable(xmlNotationTablePtr table);
99void xmlDumpNotationTable(xmlBufferPtr buf,
100 xmlNotationTablePtr table);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000101
102/* Element Content */
Daniel Veillardc26087b1999-08-30 11:23:51 +0000103xmlElementContentPtr xmlNewElementContent (CHAR *name,
104 xmlElementContentType type);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000105xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
Daniel Veillardb96e6431999-08-29 21:02:19 +0000106void xmlFreeElementContent(xmlElementContentPtr cur);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000107
108/* Element */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000109xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt,
110 xmlDtdPtr dtd,
111 const CHAR *name,
Daniel Veillardc26087b1999-08-30 11:23:51 +0000112 xmlElementContentType type,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000113 xmlElementContentPtr content);
114xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
115void xmlFreeElementTable (xmlElementTablePtr table);
116void xmlDumpElementTable (xmlBufferPtr buf,
117 xmlElementTablePtr table);
Daniel Veillard3b9def11999-01-31 22:15:06 +0000118
Daniel Veillard1e346af1999-02-22 10:33:01 +0000119/* Enumeration */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000120xmlEnumerationPtr xmlCreateEnumeration (CHAR *name);
121void xmlFreeEnumeration (xmlEnumerationPtr cur);
122xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000123
124/* Attribute */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000125xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
126 xmlDtdPtr dtd,
127 const CHAR *elem,
128 const CHAR *name,
Daniel Veillardc26087b1999-08-30 11:23:51 +0000129 xmlAttributeType type,
130 xmlAttributeDefault def,
Daniel Veillardb96e6431999-08-29 21:02:19 +0000131 const CHAR *defaultValue,
132 xmlEnumerationPtr tree);
133xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
134void xmlFreeAttributeTable (xmlAttributeTablePtr table);
135void xmlDumpAttributeTable (xmlBufferPtr buf,
136 xmlAttributeTablePtr table);
Daniel Veillard1e346af1999-02-22 10:33:01 +0000137
Daniel Veillard991e63d1999-08-15 23:32:28 +0000138/* IDs */
Daniel Veillardb96e6431999-08-29 21:02:19 +0000139xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt,
140 xmlDocPtr doc,
141 const CHAR *value,
142 xmlAttrPtr attr);
143xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table);
144void xmlFreeIDTable (xmlIDTablePtr table);
145xmlAttrPtr xmlGetID (xmlDocPtr doc,
146 const CHAR *ID);
147int xmlIsID (xmlDocPtr doc,
148 xmlNodePtr elem,
149 xmlAttrPtr attr);
Daniel Veillard991e63d1999-08-15 23:32:28 +0000150
Daniel Veillardb05deb71999-08-10 19:04:08 +0000151/**
152 * The public function calls related to validity checking
153 */
154
Daniel Veillardb96e6431999-08-29 21:02:19 +0000155int xmlValidateRoot (xmlValidCtxtPtr ctxt,
156 xmlDocPtr doc);
157int xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
158 xmlDocPtr doc,
159 xmlElementPtr elem);
160int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
161 xmlDocPtr doc,
162 xmlAttributePtr attr);
163int xmlValidateAttributeValue(xmlAttributeType type,
164 const CHAR *value);
165int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
166 xmlDocPtr doc,
167 xmlNotationPtr nota);
168int xmlValidateDtd (xmlValidCtxtPtr ctxt,
169 xmlDocPtr doc,
170 xmlDtdPtr dtd);
171int xmlValidateDocument (xmlValidCtxtPtr ctxt,
172 xmlDocPtr doc);
173int xmlValidateElement (xmlValidCtxtPtr ctxt,
174 xmlDocPtr doc,
175 xmlNodePtr elem);
176int xmlValidateOneElement (xmlValidCtxtPtr ctxt,
177 xmlDocPtr doc,
178 xmlNodePtr elem);
179int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
180 xmlDocPtr doc,
181 xmlNodePtr elem,
182 xmlAttrPtr attr,
183 const CHAR *value);
184int xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
185 xmlDocPtr doc,
186 const CHAR *notationName);
187int xmlIsMixedElement (xmlDocPtr doc,
188 const CHAR *name);
189xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd,
190 const CHAR *elem,
191 const CHAR *name);
192xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd,
193 const CHAR *name);
194xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd,
195 const CHAR *name);
Daniel Veillardc26087b1999-08-30 11:23:51 +0000196
197#ifdef __cplusplus
198}
199#endif
Daniel Veillard39a1f9a1999-01-17 19:11:59 +0000200#endif /* __XML_VALID_H__ */