2 * valid.h : interface to the DTD handling and the validity checking
4 * See Copyright for the status of this software.
10 #ifndef __XML_VALID_H__
11 #define __XML_VALID_H__
13 #include <libxml/tree.h>
14 #include <libxml/list.h>
15 #include <libxml/xmlautomata.h>
16 #include <libxml/xmlregexp.h>
23 * Validation state added for non-determinist content model.
25 typedef struct _xmlValidState xmlValidState;
26 typedef xmlValidState *xmlValidStatePtr;
29 * xmlValidityErrorFunc:
30 * @ctx: an xmlValidCtxtPtr validity error context
31 * @msg: the string to format *printf like vararg
32 * @...: remaining arguments to the format
34 * Callback called when a validity error is found. This is a message
35 * oriented function similar to an *printf function.
37 typedef void (*xmlValidityErrorFunc) (void *ctx,
42 * xmlValidityWarningFunc:
43 * @ctx: an xmlValidCtxtPtr validity error context
44 * @msg: the string to format *printf like vararg
45 * @...: remaining arguments to the format
47 * Callback called when a validity warning is found. This is a message
48 * oriented function similar to an *printf function.
50 typedef void (*xmlValidityWarningFunc) (void *ctx,
56 * An xmlValidCtxt is used for error reporting when validating.
58 typedef struct _xmlValidCtxt xmlValidCtxt;
59 typedef xmlValidCtxt *xmlValidCtxtPtr;
60 struct _xmlValidCtxt {
61 void *userData; /* user specific data block */
62 xmlValidityErrorFunc error; /* the callback in case of errors */
63 xmlValidityWarningFunc warning; /* the callback in case of warning */
65 /* Node analysis stack used when validating within entities */
66 xmlNodePtr node; /* Current parsed Node */
67 int nodeNr; /* Depth of the parsing stack */
68 int nodeMax; /* Max depth of the parsing stack */
69 xmlNodePtr *nodeTab; /* array of nodes */
71 int finishDtd; /* finished validating the Dtd ? */
72 xmlDocPtr doc; /* the document */
73 int valid; /* temporary validity check result */
75 /* state state used for non-determinist content validation */
76 xmlValidState *vstate; /* current state */
77 int vstateNr; /* Depth of the validation stack */
78 int vstateMax; /* Max depth of the validation stack */
79 xmlValidState *vstateTab; /* array of validation states */
81 #ifdef LIBXML_REGEXP_ENABLED
82 xmlAutomataPtr am; /* the automata */
83 xmlAutomataStatePtr state; /* used to build the automata */
91 * ALL notation declarations are stored in a table.
92 * There is one table per DTD.
95 typedef struct _xmlHashTable xmlNotationTable;
96 typedef xmlNotationTable *xmlNotationTablePtr;
99 * ALL element declarations are stored in a table.
100 * There is one table per DTD.
103 typedef struct _xmlHashTable xmlElementTable;
104 typedef xmlElementTable *xmlElementTablePtr;
107 * ALL attribute declarations are stored in a table.
108 * There is one table per DTD.
111 typedef struct _xmlHashTable xmlAttributeTable;
112 typedef xmlAttributeTable *xmlAttributeTablePtr;
115 * ALL IDs attributes are stored in a table.
116 * There is one table per document.
119 typedef struct _xmlHashTable xmlIDTable;
120 typedef xmlIDTable *xmlIDTablePtr;
123 * ALL Refs attributes are stored in a table.
124 * There is one table per document.
127 typedef struct _xmlHashTable xmlRefTable;
128 typedef xmlRefTable *xmlRefTablePtr;
131 xmlChar * xmlSplitQName2 (const xmlChar *name,
135 xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
138 const xmlChar *PublicID,
139 const xmlChar *SystemID);
140 xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
141 void xmlFreeNotationTable(xmlNotationTablePtr table);
142 void xmlDumpNotationDecl (xmlBufferPtr buf,
143 xmlNotationPtr nota);
144 void xmlDumpNotationTable(xmlBufferPtr buf,
145 xmlNotationTablePtr table);
147 /* Element Content */
148 xmlElementContentPtr xmlNewElementContent (xmlChar *name,
149 xmlElementContentType type);
150 xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
151 void xmlFreeElementContent(xmlElementContentPtr cur);
152 void xmlSnprintfElementContent(char *buf,
154 xmlElementContentPtr content,
157 void xmlSprintfElementContent(char *buf,
158 xmlElementContentPtr content,
163 xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt,
166 xmlElementTypeVal type,
167 xmlElementContentPtr content);
168 xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
169 void xmlFreeElementTable (xmlElementTablePtr table);
170 void xmlDumpElementTable (xmlBufferPtr buf,
171 xmlElementTablePtr table);
172 void xmlDumpElementDecl (xmlBufferPtr buf,
176 xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name);
177 void xmlFreeEnumeration (xmlEnumerationPtr cur);
178 xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur);
181 xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
186 xmlAttributeType type,
187 xmlAttributeDefault def,
188 const xmlChar *defaultValue,
189 xmlEnumerationPtr tree);
190 xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table);
191 void xmlFreeAttributeTable (xmlAttributeTablePtr table);
192 void xmlDumpAttributeTable (xmlBufferPtr buf,
193 xmlAttributeTablePtr table);
194 void xmlDumpAttributeDecl (xmlBufferPtr buf,
195 xmlAttributePtr attr);
198 xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt,
200 const xmlChar *value,
202 void xmlFreeIDTable (xmlIDTablePtr table);
203 xmlAttrPtr xmlGetID (xmlDocPtr doc,
205 int xmlIsID (xmlDocPtr doc,
208 int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr);
211 xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt,
213 const xmlChar *value,
215 void xmlFreeRefTable (xmlRefTablePtr table);
216 int xmlIsRef (xmlDocPtr doc,
219 int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr);
220 xmlListPtr xmlGetRefs (xmlDocPtr doc,
224 * The public function calls related to validity checking.
227 int xmlValidateRoot (xmlValidCtxtPtr ctxt,
229 int xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
232 xmlChar * xmlValidNormalizeAttributeValue(xmlDocPtr doc,
235 const xmlChar *value);
236 xmlChar * xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
240 const xmlChar *value);
241 int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
243 xmlAttributePtr attr);
244 int xmlValidateAttributeValue(xmlAttributeType type,
245 const xmlChar *value);
246 int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
248 xmlNotationPtr nota);
249 int xmlValidateDtd (xmlValidCtxtPtr ctxt,
252 int xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
254 int xmlValidateDocument (xmlValidCtxtPtr ctxt,
256 int xmlValidateElement (xmlValidCtxtPtr ctxt,
259 int xmlValidateOneElement (xmlValidCtxtPtr ctxt,
262 int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
266 const xmlChar *value);
267 int xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
270 const xmlChar *prefix,
272 const xmlChar *value);
273 int xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
275 int xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
277 const xmlChar *notationName);
278 int xmlIsMixedElement (xmlDocPtr doc,
279 const xmlChar *name);
280 xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd,
282 const xmlChar *name);
283 xmlAttributePtr xmlGetDtdQAttrDesc (xmlDtdPtr dtd,
286 const xmlChar *prefix);
287 xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd,
288 const xmlChar *name);
289 xmlElementPtr xmlGetDtdQElementDesc (xmlDtdPtr dtd,
291 const xmlChar *prefix);
292 xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd,
293 const xmlChar *name);
295 int xmlValidGetValidElements(xmlNode *prev,
297 const xmlChar **list,
299 int xmlValidGetPotentialChildren(xmlElementContent *ctree,
300 const xmlChar **list,
303 int xmlValidateNameValue (const xmlChar *value);
304 int xmlValidateNamesValue (const xmlChar *value);
305 int xmlValidateNmtokenValue (const xmlChar *value);
306 int xmlValidateNmtokensValue(const xmlChar *value);
308 #ifdef LIBXML_REGEXP_ENABLED
310 * Validation based on the regexp support
312 int xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
315 int xmlValidatePushElement (xmlValidCtxtPtr ctxt,
318 const xmlChar *qname);
319 int xmlValidatePushCData (xmlValidCtxtPtr ctxt,
322 int xmlValidatePopElement (xmlValidCtxtPtr ctxt,
325 const xmlChar *qname);
326 #endif /* LIBXML_REGEXP_ENABLED */
330 #endif /* __XML_VALID_H__ */