2 * Summary: The DTD validation
3 * Description: API for the DTD handling and the validity checking
5 * Copy: See Copyright for the status of this software.
7 * Author: Daniel Veillard
8 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
19 #include <stdapis/libxml2/libxml2_xmlerror.h>
20 #include <stdapis/libxml2/libxml2_tree.h>
21 #include <stdapis/libxml2/libxml2_list.h>
23 #ifdef LIBXML_AUTOMATA_ENABLED
24 #include "libxml2_xmlautomata.h"
27 #ifdef LIBXML_REGEXP_ENABLED
28 #include "libxml2_xmlregexp.h"
36 * Validation state added for non-determinist content model.
38 typedef struct _xmlValidState xmlValidState;
39 typedef xmlValidState *xmlValidStatePtr;
42 * xmlValidityErrorFunc:
43 * @param ctx an xmlValidCtxtPtr validity error context
44 * @param msg the string to format *printf like vararg
45 * @param # remaining arguments to the format
47 * Callback called when a validity error is found. This is a message
48 * oriented function similar to an *printf function.
50 typedef void (*xmlValidityErrorFunc) (void *ctx,
55 * xmlValidityWarningFunc:
56 * @param ctx an xmlValidCtxtPtr validity error context
57 * @param msg the string to format *printf like vararg
58 * @param # remaining arguments to the format
60 * Callback called when a validity warning is found. This is a message
61 * oriented function similar to an *printf function.
63 typedef void (*xmlValidityWarningFunc) (void *ctx,
69 * An xmlValidCtxt is used for error reporting when validating.
71 typedef struct _xmlValidCtxt xmlValidCtxt;
72 typedef xmlValidCtxt *xmlValidCtxtPtr;
73 struct _xmlValidCtxt {
74 void *userData; /* user specific data block */
75 xmlValidityErrorFunc error; /* the callback in case of errors */
76 xmlValidityWarningFunc warning; /* the callback in case of warning */
78 /* Node analysis stack used when validating within entities */
79 xmlNodePtr node; /* Current parsed Node */
80 int nodeNr; /* Depth of the parsing stack */
81 int nodeMax; /* Max depth of the parsing stack */
82 xmlNodePtr* nodeTab; /* array of nodes */
84 int finishDtd; /* finished validating the Dtd ? */
85 xmlDocPtr doc; /* the document */
86 int valid; /* temporary validity check result */
88 /* state state used for non-determinist content validation */
89 xmlValidState* vstate; /* current state */
90 int vstateNr; /* Depth of the validation stack */
91 int vstateMax; /* Max depth of the validation stack */
92 xmlValidState* vstateTab; /* array of validation states */
94 #ifdef LIBXML_REGEXP_ENABLED
95 xmlAutomataPtr am; /* the automata */
96 xmlAutomataStatePtr state; /* used to build the automata */
104 * ALL notation declarations are stored in a table.
105 * There is one table per DTD.
108 typedef struct _xmlHashTable xmlNotationTable;
109 typedef xmlNotationTable *xmlNotationTablePtr;
112 * ALL element declarations are stored in a table.
113 * There is one table per DTD.
116 typedef struct _xmlHashTable xmlElementTable;
117 typedef xmlElementTable *xmlElementTablePtr;
120 * ALL attribute declarations are stored in a table.
121 * There is one table per DTD.
124 typedef struct _xmlHashTable xmlAttributeTable;
125 typedef xmlAttributeTable *xmlAttributeTablePtr;
128 * ALL IDs attributes are stored in a table.
129 * There is one table per document.
132 typedef struct _xmlHashTable xmlIDTable;
133 typedef xmlIDTable *xmlIDTablePtr;
136 * ALL Refs attributes are stored in a table.
137 * There is one table per document.
140 typedef struct _xmlHashTable xmlRefTable;
141 typedef xmlRefTable *xmlRefTablePtr;
143 /* Allocate/Release Validation Contexts */
144 XMLPUBFUN xmlValidCtxtPtr XMLCALL
145 xmlNewValidCtxt(void);
146 XMLPUBFUN void XMLCALL
147 xmlFreeValidCtxt(xmlValidCtxtPtr);
150 XMLPUBFUN xmlNotationPtr XMLCALL
151 xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
154 const xmlChar *PublicID,
155 const xmlChar *SystemID);
156 XMLPUBFUN xmlNotationTablePtr XMLCALL
157 xmlCopyNotationTable (xmlNotationTablePtr table);
158 XMLPUBFUN void XMLCALL
159 xmlFreeNotationTable (xmlNotationTablePtr table);
160 #ifdef LIBXML_OUTPUT_ENABLED
161 XMLPUBFUN void XMLCALL
162 xmlDumpNotationDecl (xmlBufferPtr buf,
163 xmlNotationPtr nota);
164 XMLPUBFUN void XMLCALL
165 xmlDumpNotationTable (xmlBufferPtr buf,
166 xmlNotationTablePtr table);
167 #endif /* LIBXML_OUTPUT_ENABLED */
169 /* Element Content */
170 XMLPUBFUN xmlElementContentPtr XMLCALL
171 xmlNewElementContent (const xmlChar *name,
172 xmlElementContentType type);
173 XMLPUBFUN xmlElementContentPtr XMLCALL
174 xmlCopyElementContent (xmlElementContentPtr content);
175 XMLPUBFUN void XMLCALL
176 xmlFreeElementContent (xmlElementContentPtr cur);
177 XMLPUBFUN void XMLCALL
178 xmlSnprintfElementContent(char *buf,
180 xmlElementContentPtr content,
183 XMLPUBFUN void XMLCALL
184 xmlSprintfElementContent(char *buf,
185 xmlElementContentPtr content,
190 XMLPUBFUN xmlElementPtr XMLCALL
191 xmlAddElementDecl (xmlValidCtxtPtr ctxt,
194 xmlElementTypeVal type,
195 xmlElementContentPtr content);
196 XMLPUBFUN xmlElementTablePtr XMLCALL
197 xmlCopyElementTable (xmlElementTablePtr table);
198 XMLPUBFUN void XMLCALL
199 xmlFreeElementTable (xmlElementTablePtr table);
200 #ifdef LIBXML_OUTPUT_ENABLED
201 XMLPUBFUN void XMLCALL
202 xmlDumpElementTable (xmlBufferPtr buf,
203 xmlElementTablePtr table);
204 XMLPUBFUN void XMLCALL
205 xmlDumpElementDecl (xmlBufferPtr buf,
207 #endif /* LIBXML_OUTPUT_ENABLED */
210 XMLPUBFUN xmlEnumerationPtr XMLCALL
211 xmlCreateEnumeration (const xmlChar *name);
212 XMLPUBFUN void XMLCALL
213 xmlFreeEnumeration (xmlEnumerationPtr cur);
214 XMLPUBFUN xmlEnumerationPtr XMLCALL
215 xmlCopyEnumeration (xmlEnumerationPtr cur);
218 XMLPUBFUN xmlAttributePtr XMLCALL
219 xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
224 xmlAttributeType type,
225 xmlAttributeDefault def,
226 const xmlChar *defaultValue,
227 xmlEnumerationPtr tree);
228 XMLPUBFUN xmlAttributeTablePtr XMLCALL
229 xmlCopyAttributeTable (xmlAttributeTablePtr table);
230 XMLPUBFUN void XMLCALL
231 xmlFreeAttributeTable (xmlAttributeTablePtr table);
232 #ifdef LIBXML_OUTPUT_ENABLED
233 XMLPUBFUN void XMLCALL
234 xmlDumpAttributeTable (xmlBufferPtr buf,
235 xmlAttributeTablePtr table);
236 XMLPUBFUN void XMLCALL
237 xmlDumpAttributeDecl (xmlBufferPtr buf,
238 xmlAttributePtr attr);
239 #endif /* LIBXML_OUTPUT_ENABLED */
241 XMLPUBFUN xmlIDPtr XMLCALL
242 xmlAddID (xmlValidCtxtPtr ctxt,
244 const xmlChar *value,
246 XMLPUBFUN void XMLCALL
247 xmlFreeIDTable (xmlIDTablePtr table);
248 XMLPUBFUN xmlAttrPtr XMLCALL
249 xmlGetID (xmlDocPtr doc,
251 XMLPUBFUN int XMLCALL
252 xmlIsID (xmlDocPtr doc,
255 XMLPUBFUN int XMLCALL
256 xmlRemoveID (xmlDocPtr doc,
261 XMLPUBFUN xmlRefPtr XMLCALL
262 xmlAddRef (xmlValidCtxtPtr ctxt,
264 const xmlChar *value,
266 XMLPUBFUN void XMLCALL
267 xmlFreeRefTable (xmlRefTablePtr table);
268 XMLPUBFUN int XMLCALL
269 xmlIsRef (xmlDocPtr doc,
272 XMLPUBFUN int XMLCALL
273 xmlRemoveRef (xmlDocPtr doc,
276 #ifndef XMLENGINE_EXCLUDE_UNUSED
277 XMLPUBFUN xmlListPtr XMLCALL
278 xmlGetRefs (xmlDocPtr doc, const xmlChar *ID);
279 #endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
282 * The public function calls related to validity checking.
285 XMLPUBFUN int XMLCALL
286 xmlValidateRoot (xmlValidCtxtPtr ctxt,
288 XMLPUBFUN int XMLCALL
289 xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
292 XMLPUBFUN xmlChar * XMLCALL
293 xmlValidNormalizeAttributeValue(xmlDocPtr doc,
296 const xmlChar *value);
297 XMLPUBFUN xmlChar * XMLCALL
298 xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
302 const xmlChar *value);
303 XMLPUBFUN int XMLCALL
304 xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
306 xmlAttributePtr attr);
307 XMLPUBFUN int XMLCALL
308 xmlValidateAttributeValue(xmlAttributeType type,
309 const xmlChar *value);
310 XMLPUBFUN int XMLCALL
311 xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
313 xmlNotationPtr nota);
314 XMLPUBFUN int XMLCALL
315 xmlValidateDtd (xmlValidCtxtPtr ctxt,
318 XMLPUBFUN int XMLCALL
319 xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
321 XMLPUBFUN int XMLCALL
322 xmlValidateDocument (xmlValidCtxtPtr ctxt,
324 XMLPUBFUN int XMLCALL
325 xmlValidateElement (xmlValidCtxtPtr ctxt,
328 XMLPUBFUN int XMLCALL
329 xmlValidateOneElement (xmlValidCtxtPtr ctxt,
332 XMLPUBFUN int XMLCALL
333 xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
337 const xmlChar *value);
338 XMLPUBFUN int XMLCALL
339 xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
342 const xmlChar *prefix,
344 const xmlChar *value);
345 XMLPUBFUN int XMLCALL
346 xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
348 XMLPUBFUN int XMLCALL
349 xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
351 const xmlChar *notationName);
352 XMLPUBFUN int XMLCALL
353 xmlIsMixedElement (xmlDocPtr doc,
354 const xmlChar *name);
355 XMLPUBFUN xmlAttributePtr XMLCALL
356 xmlGetDtdAttrDesc (xmlDtdPtr dtd,
358 const xmlChar *name);
359 XMLPUBFUN xmlAttributePtr XMLCALL
360 xmlGetDtdQAttrDesc (xmlDtdPtr dtd,
363 const xmlChar *prefix);
364 XMLPUBFUN xmlNotationPtr XMLCALL
365 xmlGetDtdNotationDesc (xmlDtdPtr dtd,
366 const xmlChar *name);
367 XMLPUBFUN xmlElementPtr XMLCALL
368 xmlGetDtdQElementDesc (xmlDtdPtr dtd,
370 const xmlChar *prefix);
371 XMLPUBFUN xmlElementPtr XMLCALL
372 xmlGetDtdElementDesc (xmlDtdPtr dtd,
373 const xmlChar *name);
375 XMLPUBFUN int XMLCALL
376 xmlValidGetValidElements(xmlNode *prev,
378 const xmlChar **names,
380 XMLPUBFUN int XMLCALL
381 xmlValidGetPotentialChildren(xmlElementContent *ctree,
382 const xmlChar **list,
385 XMLPUBFUN int XMLCALL
386 xmlValidateNameValue (const xmlChar *value);
387 XMLPUBFUN int XMLCALL
388 xmlValidateNamesValue (const xmlChar *value);
389 XMLPUBFUN int XMLCALL
390 xmlValidateNmtokenValue (const xmlChar *value);
391 XMLPUBFUN int XMLCALL
392 xmlValidateNmtokensValue(const xmlChar *value);
394 #ifdef LIBXML_REGEXP_ENABLED
396 * Validation based on the regexp support
398 XMLPUBFUN int XMLCALL
399 xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
402 XMLPUBFUN int XMLCALL
403 xmlValidatePushElement (xmlValidCtxtPtr ctxt,
406 const xmlChar *qname);
407 XMLPUBFUN int XMLCALL
408 xmlValidatePushCData (xmlValidCtxtPtr ctxt,
411 XMLPUBFUN int XMLCALL
412 xmlValidatePopElement (xmlValidCtxtPtr ctxt,
415 const xmlChar *qname);
416 #endif /* LIBXML_REGEXP_ENABLED */
420 #endif /* XML_VALID_H */