blob: a7eb675d850cf5d27d62df30a3144603028af9b8 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +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
13#include <libxml/tree.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/**
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 xmlValidCtxt;
27typedef xmlValidCtxt *xmlValidCtxtPtr;
28struct _xmlValidCtxt {
29 void *userData; /* user specific data block */
30 xmlValidityErrorFunc error; /* the callback in case of errors */
31 xmlValidityWarningFunc warning; /* the callback in case of warning */
32
33 /* Node analysis stack used when validating within entities */
34 xmlNodePtr node; /* Current parsed Node */
35 int nodeNr; /* Depth of the parsing stack */
36 int nodeMax; /* Max depth of the parsing stack */
37 xmlNodePtr *nodeTab; /* array of nodes */
38
39 int finishDtd; /* finished validating the Dtd ? */
40 xmlDocPtr doc; /* the document */
41 int valid; /* temporary validity check result */
42};
43
44/*
45 * ALl notation declarations are stored in a table
46 * there is one table per DTD
47 */
48
49typedef struct _xmlHashTable xmlNotationTable;
50typedef xmlNotationTable *xmlNotationTablePtr;
51
52/*
53 * ALl element declarations are stored in a table
54 * there is one table per DTD
55 */
56
57typedef struct _xmlHashTable xmlElementTable;
58typedef xmlElementTable *xmlElementTablePtr;
59
60/*
61 * ALl attribute declarations are stored in a table
62 * there is one table per DTD
63 */
64
65typedef struct _xmlHashTable xmlAttributeTable;
66typedef xmlAttributeTable *xmlAttributeTablePtr;
67
68/*
69 * ALl IDs attributes are stored in a table
70 * there is one table per document
71 */
72
73typedef struct _xmlHashTable xmlIDTable;
74typedef xmlIDTable *xmlIDTablePtr;
75
76/*
77 * ALl Refs attributes are stored in a table
78 * there is one table per document
79 */
80
81typedef struct _xmlHashTable xmlRefTable;
82typedef xmlRefTable *xmlRefTablePtr;
83
84/* helper */
85xmlChar * xmlSplitQName2 (const xmlChar *name,
86 xmlChar **prefix);
87
88/* Notation */
89xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
90 xmlDtdPtr dtd,
91 const xmlChar *name,
92 const xmlChar *PublicID,
93 const xmlChar *SystemID);
94xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
95void xmlFreeNotationTable(xmlNotationTablePtr table);
96void xmlDumpNotationDecl (xmlBufferPtr buf,
97 xmlNotationPtr nota);
98void xmlDumpNotationTable(xmlBufferPtr buf,
99 xmlNotationTablePtr table);
100
101/* Element Content */
102xmlElementContentPtr xmlNewElementContent (xmlChar *name,
103 xmlElementContentType type);
104xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
105void xmlFreeElementContent(xmlElementContentPtr cur);
106void xmlSprintfElementContent(char *buf,
107 xmlElementContentPtr content,
108 int glob);
109
110/* Element */
111xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt,
112 xmlDtdPtr dtd,
113 const xmlChar *name,
114 xmlElementTypeVal type,
115 xmlElementContentPtr content);
116xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
117void xmlFreeElementTable (xmlElementTablePtr table);
118void xmlDumpElementTable (xmlBufferPtr buf,
119 xmlElementTablePtr table);
120void xmlDumpElementDecl (xmlBufferPtr buf,
121 xmlElementPtr elem);
122
123/* Enumeration */
124xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name);
125void xmlFreeEnumeration (xmlEnumerationPtr cur);
126xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
127
128/* Attribute */
129xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
130 xmlDtdPtr dtd,
131 const xmlChar *elem,
132 const xmlChar *name,
133 const xmlChar *ns,
134 xmlAttributeType type,
135 xmlAttributeDefault def,
136 const xmlChar *defaultValue,
137 xmlEnumerationPtr tree);
138xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
139void xmlFreeAttributeTable (xmlAttributeTablePtr table);
140void xmlDumpAttributeTable (xmlBufferPtr buf,
141 xmlAttributeTablePtr table);
142void xmlDumpAttributeDecl (xmlBufferPtr buf,
143 xmlAttributePtr attr);
144
145/* IDs */
146xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt,
147 xmlDocPtr doc,
148 const xmlChar *value,
149 xmlAttrPtr attr);
150xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table);
151void xmlFreeIDTable (xmlIDTablePtr table);
152xmlAttrPtr xmlGetID (xmlDocPtr doc,
153 const xmlChar *ID);
154int xmlIsID (xmlDocPtr doc,
155 xmlNodePtr elem,
156 xmlAttrPtr attr);
157int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr);
158
159/* IDREFs */
160xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt,
161 xmlDocPtr doc,
162 const xmlChar *value,
163 xmlAttrPtr attr);
164xmlRefTablePtr xmlCopyRefTable (xmlRefTablePtr table);
165void xmlFreeRefTable (xmlRefTablePtr table);
166int xmlIsRef (xmlDocPtr doc,
167 xmlNodePtr elem,
168 xmlAttrPtr attr);
169int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr);
170
171/**
172 * The public function calls related to validity checking
173 */
174
175int xmlValidateRoot (xmlValidCtxtPtr ctxt,
176 xmlDocPtr doc);
177int xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
178 xmlDocPtr doc,
179 xmlElementPtr elem);
180xmlChar * xmlValidNormalizeAttributeValue(xmlDocPtr doc,
181 xmlNodePtr elem,
182 const xmlChar *name,
183 const xmlChar *value);
184int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
185 xmlDocPtr doc,
186 xmlAttributePtr attr);
187int xmlValidateAttributeValue(xmlAttributeType type,
188 const xmlChar *value);
189int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
190 xmlDocPtr doc,
191 xmlNotationPtr nota);
192int xmlValidateDtd (xmlValidCtxtPtr ctxt,
193 xmlDocPtr doc,
194 xmlDtdPtr dtd);
195int xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
196 xmlDocPtr doc);
197int xmlValidateDocument (xmlValidCtxtPtr ctxt,
198 xmlDocPtr doc);
199int xmlValidateElement (xmlValidCtxtPtr ctxt,
200 xmlDocPtr doc,
201 xmlNodePtr elem);
202int xmlValidateOneElement (xmlValidCtxtPtr ctxt,
203 xmlDocPtr doc,
204 xmlNodePtr elem);
205int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
206 xmlDocPtr doc,
207 xmlNodePtr elem,
208 xmlAttrPtr attr,
209 const xmlChar *value);
210int xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
211 xmlDocPtr doc);
212int xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
213 xmlDocPtr doc,
214 const xmlChar *notationName);
215int xmlIsMixedElement (xmlDocPtr doc,
216 const xmlChar *name);
217xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd,
218 const xmlChar *elem,
219 const xmlChar *name);
220xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd,
221 const xmlChar *name);
222xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd,
223 const xmlChar *name);
224
225int xmlValidGetValidElements(xmlNode *prev,
226 xmlNode *next,
227 const xmlChar **list,
228 int max);
229int xmlValidGetPotentialChildren(xmlElementContent *ctree,
230 const xmlChar **list,
231 int *len,
232 int max);
233#ifdef __cplusplus
234}
235#endif
236#endif /* __XML_VALID_H__ */