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