Eneboo - Documentación para desarrolladores
|
00001 /* 00002 * Summary: The DTD validation 00003 * Description: API for the DTD handling and the validity checking 00004 * 00005 * Copy: See Copyright for the status of this software. 00006 * 00007 * Author: Daniel Veillard 00008 */ 00009 00010 00011 #ifndef __XML_VALID_H__ 00012 #define __XML_VALID_H__ 00013 00014 #include <libxml/xmlversion.h> 00015 #include <libxml/xmlerror.h> 00016 #include <libxml/tree.h> 00017 #include <libxml/list.h> 00018 #include <libxml/xmlautomata.h> 00019 #include <libxml/xmlregexp.h> 00020 00021 #ifdef __cplusplus 00022 extern "C" { 00023 #endif 00024 00025 /* 00026 * Validation state added for non-determinist content model. 00027 */ 00028 typedef struct _xmlValidState xmlValidState; 00029 typedef xmlValidState *xmlValidStatePtr; 00030 00042 typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx, 00043 const char *msg, 00044 ...) LIBXML_ATTR_FORMAT(2,3); 00045 00057 typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx, 00058 const char *msg, 00059 ...) LIBXML_ATTR_FORMAT(2,3); 00060 00061 #ifdef IN_LIBXML 00062 00067 #define XML_CTXT_FINISH_DTD_0 0xabcd1234 00068 00073 #define XML_CTXT_FINISH_DTD_1 0xabcd1235 00074 #endif 00075 00076 /* 00077 * xmlValidCtxt: 00078 * An xmlValidCtxt is used for error reporting when validating. 00079 */ 00080 typedef struct _xmlValidCtxt xmlValidCtxt; 00081 typedef xmlValidCtxt *xmlValidCtxtPtr; 00082 struct _xmlValidCtxt { 00083 void *userData; /* user specific data block */ 00084 xmlValidityErrorFunc error; /* the callback in case of errors */ 00085 xmlValidityWarningFunc warning; /* the callback in case of warning */ 00086 00087 /* Node analysis stack used when validating within entities */ 00088 xmlNodePtr node; /* Current parsed Node */ 00089 int nodeNr; /* Depth of the parsing stack */ 00090 int nodeMax; /* Max depth of the parsing stack */ 00091 xmlNodePtr *nodeTab; /* array of nodes */ 00092 00093 unsigned int finishDtd; /* finished validating the Dtd ? */ 00094 xmlDocPtr doc; /* the document */ 00095 int valid; /* temporary validity check result */ 00096 00097 /* state state used for non-determinist content validation */ 00098 xmlValidState *vstate; /* current state */ 00099 int vstateNr; /* Depth of the validation stack */ 00100 int vstateMax; /* Max depth of the validation stack */ 00101 xmlValidState *vstateTab; /* array of validation states */ 00102 00103 #ifdef LIBXML_REGEXP_ENABLED 00104 xmlAutomataPtr am; /* the automata */ 00105 xmlAutomataStatePtr state; /* used to build the automata */ 00106 #else 00107 void *am; 00108 void *state; 00109 #endif 00110 }; 00111 00112 /* 00113 * ALL notation declarations are stored in a table. 00114 * There is one table per DTD. 00115 */ 00116 00117 typedef struct _xmlHashTable xmlNotationTable; 00118 typedef xmlNotationTable *xmlNotationTablePtr; 00119 00120 /* 00121 * ALL element declarations are stored in a table. 00122 * There is one table per DTD. 00123 */ 00124 00125 typedef struct _xmlHashTable xmlElementTable; 00126 typedef xmlElementTable *xmlElementTablePtr; 00127 00128 /* 00129 * ALL attribute declarations are stored in a table. 00130 * There is one table per DTD. 00131 */ 00132 00133 typedef struct _xmlHashTable xmlAttributeTable; 00134 typedef xmlAttributeTable *xmlAttributeTablePtr; 00135 00136 /* 00137 * ALL IDs attributes are stored in a table. 00138 * There is one table per document. 00139 */ 00140 00141 typedef struct _xmlHashTable xmlIDTable; 00142 typedef xmlIDTable *xmlIDTablePtr; 00143 00144 /* 00145 * ALL Refs attributes are stored in a table. 00146 * There is one table per document. 00147 */ 00148 00149 typedef struct _xmlHashTable xmlRefTable; 00150 typedef xmlRefTable *xmlRefTablePtr; 00151 00152 /* Notation */ 00153 XMLPUBFUN xmlNotationPtr XMLCALL 00154 xmlAddNotationDecl (xmlValidCtxtPtr ctxt, 00155 xmlDtdPtr dtd, 00156 const xmlChar *name, 00157 const xmlChar *PublicID, 00158 const xmlChar *SystemID); 00159 #ifdef LIBXML_TREE_ENABLED 00160 XMLPUBFUN xmlNotationTablePtr XMLCALL 00161 xmlCopyNotationTable (xmlNotationTablePtr table); 00162 #endif /* LIBXML_TREE_ENABLED */ 00163 XMLPUBFUN void XMLCALL 00164 xmlFreeNotationTable (xmlNotationTablePtr table); 00165 #ifdef LIBXML_OUTPUT_ENABLED 00166 XMLPUBFUN void XMLCALL 00167 xmlDumpNotationDecl (xmlBufferPtr buf, 00168 xmlNotationPtr nota); 00169 XMLPUBFUN void XMLCALL 00170 xmlDumpNotationTable (xmlBufferPtr buf, 00171 xmlNotationTablePtr table); 00172 #endif /* LIBXML_OUTPUT_ENABLED */ 00173 00174 /* Element Content */ 00175 /* the non Doc version are being deprecated */ 00176 XMLPUBFUN xmlElementContentPtr XMLCALL 00177 xmlNewElementContent (const xmlChar *name, 00178 xmlElementContentType type); 00179 XMLPUBFUN xmlElementContentPtr XMLCALL 00180 xmlCopyElementContent (xmlElementContentPtr content); 00181 XMLPUBFUN void XMLCALL 00182 xmlFreeElementContent (xmlElementContentPtr cur); 00183 /* the new versions with doc argument */ 00184 XMLPUBFUN xmlElementContentPtr XMLCALL 00185 xmlNewDocElementContent (xmlDocPtr doc, 00186 const xmlChar *name, 00187 xmlElementContentType type); 00188 XMLPUBFUN xmlElementContentPtr XMLCALL 00189 xmlCopyDocElementContent(xmlDocPtr doc, 00190 xmlElementContentPtr content); 00191 XMLPUBFUN void XMLCALL 00192 xmlFreeDocElementContent(xmlDocPtr doc, 00193 xmlElementContentPtr cur); 00194 XMLPUBFUN void XMLCALL 00195 xmlSnprintfElementContent(char *buf, 00196 int size, 00197 xmlElementContentPtr content, 00198 int englob); 00199 #ifdef LIBXML_OUTPUT_ENABLED 00200 /* DEPRECATED */ 00201 XMLPUBFUN void XMLCALL 00202 xmlSprintfElementContent(char *buf, 00203 xmlElementContentPtr content, 00204 int englob); 00205 #endif /* LIBXML_OUTPUT_ENABLED */ 00206 /* DEPRECATED */ 00207 00208 /* Element */ 00209 XMLPUBFUN xmlElementPtr XMLCALL 00210 xmlAddElementDecl (xmlValidCtxtPtr ctxt, 00211 xmlDtdPtr dtd, 00212 const xmlChar *name, 00213 xmlElementTypeVal type, 00214 xmlElementContentPtr content); 00215 #ifdef LIBXML_TREE_ENABLED 00216 XMLPUBFUN xmlElementTablePtr XMLCALL 00217 xmlCopyElementTable (xmlElementTablePtr table); 00218 #endif /* LIBXML_TREE_ENABLED */ 00219 XMLPUBFUN void XMLCALL 00220 xmlFreeElementTable (xmlElementTablePtr table); 00221 #ifdef LIBXML_OUTPUT_ENABLED 00222 XMLPUBFUN void XMLCALL 00223 xmlDumpElementTable (xmlBufferPtr buf, 00224 xmlElementTablePtr table); 00225 XMLPUBFUN void XMLCALL 00226 xmlDumpElementDecl (xmlBufferPtr buf, 00227 xmlElementPtr elem); 00228 #endif /* LIBXML_OUTPUT_ENABLED */ 00229 00230 /* Enumeration */ 00231 XMLPUBFUN xmlEnumerationPtr XMLCALL 00232 xmlCreateEnumeration (const xmlChar *name); 00233 XMLPUBFUN void XMLCALL 00234 xmlFreeEnumeration (xmlEnumerationPtr cur); 00235 #ifdef LIBXML_TREE_ENABLED 00236 XMLPUBFUN xmlEnumerationPtr XMLCALL 00237 xmlCopyEnumeration (xmlEnumerationPtr cur); 00238 #endif /* LIBXML_TREE_ENABLED */ 00239 00240 /* Attribute */ 00241 XMLPUBFUN xmlAttributePtr XMLCALL 00242 xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, 00243 xmlDtdPtr dtd, 00244 const xmlChar *elem, 00245 const xmlChar *name, 00246 const xmlChar *ns, 00247 xmlAttributeType type, 00248 xmlAttributeDefault def, 00249 const xmlChar *defaultValue, 00250 xmlEnumerationPtr tree); 00251 #ifdef LIBXML_TREE_ENABLED 00252 XMLPUBFUN xmlAttributeTablePtr XMLCALL 00253 xmlCopyAttributeTable (xmlAttributeTablePtr table); 00254 #endif /* LIBXML_TREE_ENABLED */ 00255 XMLPUBFUN void XMLCALL 00256 xmlFreeAttributeTable (xmlAttributeTablePtr table); 00257 #ifdef LIBXML_OUTPUT_ENABLED 00258 XMLPUBFUN void XMLCALL 00259 xmlDumpAttributeTable (xmlBufferPtr buf, 00260 xmlAttributeTablePtr table); 00261 XMLPUBFUN void XMLCALL 00262 xmlDumpAttributeDecl (xmlBufferPtr buf, 00263 xmlAttributePtr attr); 00264 #endif /* LIBXML_OUTPUT_ENABLED */ 00265 00266 /* IDs */ 00267 XMLPUBFUN xmlIDPtr XMLCALL 00268 xmlAddID (xmlValidCtxtPtr ctxt, 00269 xmlDocPtr doc, 00270 const xmlChar *value, 00271 xmlAttrPtr attr); 00272 XMLPUBFUN void XMLCALL 00273 xmlFreeIDTable (xmlIDTablePtr table); 00274 XMLPUBFUN xmlAttrPtr XMLCALL 00275 xmlGetID (xmlDocPtr doc, 00276 const xmlChar *ID); 00277 XMLPUBFUN int XMLCALL 00278 xmlIsID (xmlDocPtr doc, 00279 xmlNodePtr elem, 00280 xmlAttrPtr attr); 00281 XMLPUBFUN int XMLCALL 00282 xmlRemoveID (xmlDocPtr doc, 00283 xmlAttrPtr attr); 00284 00285 /* IDREFs */ 00286 XMLPUBFUN xmlRefPtr XMLCALL 00287 xmlAddRef (xmlValidCtxtPtr ctxt, 00288 xmlDocPtr doc, 00289 const xmlChar *value, 00290 xmlAttrPtr attr); 00291 XMLPUBFUN void XMLCALL 00292 xmlFreeRefTable (xmlRefTablePtr table); 00293 XMLPUBFUN int XMLCALL 00294 xmlIsRef (xmlDocPtr doc, 00295 xmlNodePtr elem, 00296 xmlAttrPtr attr); 00297 XMLPUBFUN int XMLCALL 00298 xmlRemoveRef (xmlDocPtr doc, 00299 xmlAttrPtr attr); 00300 XMLPUBFUN xmlListPtr XMLCALL 00301 xmlGetRefs (xmlDocPtr doc, 00302 const xmlChar *ID); 00303 00307 #ifdef LIBXML_VALID_ENABLED 00308 /* Allocate/Release Validation Contexts */ 00309 XMLPUBFUN xmlValidCtxtPtr XMLCALL 00310 xmlNewValidCtxt(void); 00311 XMLPUBFUN void XMLCALL 00312 xmlFreeValidCtxt(xmlValidCtxtPtr); 00313 00314 XMLPUBFUN int XMLCALL 00315 xmlValidateRoot (xmlValidCtxtPtr ctxt, 00316 xmlDocPtr doc); 00317 XMLPUBFUN int XMLCALL 00318 xmlValidateElementDecl (xmlValidCtxtPtr ctxt, 00319 xmlDocPtr doc, 00320 xmlElementPtr elem); 00321 XMLPUBFUN xmlChar * XMLCALL 00322 xmlValidNormalizeAttributeValue(xmlDocPtr doc, 00323 xmlNodePtr elem, 00324 const xmlChar *name, 00325 const xmlChar *value); 00326 XMLPUBFUN xmlChar * XMLCALL 00327 xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, 00328 xmlDocPtr doc, 00329 xmlNodePtr elem, 00330 const xmlChar *name, 00331 const xmlChar *value); 00332 XMLPUBFUN int XMLCALL 00333 xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, 00334 xmlDocPtr doc, 00335 xmlAttributePtr attr); 00336 XMLPUBFUN int XMLCALL 00337 xmlValidateAttributeValue(xmlAttributeType type, 00338 const xmlChar *value); 00339 XMLPUBFUN int XMLCALL 00340 xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, 00341 xmlDocPtr doc, 00342 xmlNotationPtr nota); 00343 XMLPUBFUN int XMLCALL 00344 xmlValidateDtd (xmlValidCtxtPtr ctxt, 00345 xmlDocPtr doc, 00346 xmlDtdPtr dtd); 00347 XMLPUBFUN int XMLCALL 00348 xmlValidateDtdFinal (xmlValidCtxtPtr ctxt, 00349 xmlDocPtr doc); 00350 XMLPUBFUN int XMLCALL 00351 xmlValidateDocument (xmlValidCtxtPtr ctxt, 00352 xmlDocPtr doc); 00353 XMLPUBFUN int XMLCALL 00354 xmlValidateElement (xmlValidCtxtPtr ctxt, 00355 xmlDocPtr doc, 00356 xmlNodePtr elem); 00357 XMLPUBFUN int XMLCALL 00358 xmlValidateOneElement (xmlValidCtxtPtr ctxt, 00359 xmlDocPtr doc, 00360 xmlNodePtr elem); 00361 XMLPUBFUN int XMLCALL 00362 xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, 00363 xmlDocPtr doc, 00364 xmlNodePtr elem, 00365 xmlAttrPtr attr, 00366 const xmlChar *value); 00367 XMLPUBFUN int XMLCALL 00368 xmlValidateOneNamespace (xmlValidCtxtPtr ctxt, 00369 xmlDocPtr doc, 00370 xmlNodePtr elem, 00371 const xmlChar *prefix, 00372 xmlNsPtr ns, 00373 const xmlChar *value); 00374 XMLPUBFUN int XMLCALL 00375 xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, 00376 xmlDocPtr doc); 00377 #endif /* LIBXML_VALID_ENABLED */ 00378 00379 #if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) 00380 XMLPUBFUN int XMLCALL 00381 xmlValidateNotationUse (xmlValidCtxtPtr ctxt, 00382 xmlDocPtr doc, 00383 const xmlChar *notationName); 00384 #endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */ 00385 00386 XMLPUBFUN int XMLCALL 00387 xmlIsMixedElement (xmlDocPtr doc, 00388 const xmlChar *name); 00389 XMLPUBFUN xmlAttributePtr XMLCALL 00390 xmlGetDtdAttrDesc (xmlDtdPtr dtd, 00391 const xmlChar *elem, 00392 const xmlChar *name); 00393 XMLPUBFUN xmlAttributePtr XMLCALL 00394 xmlGetDtdQAttrDesc (xmlDtdPtr dtd, 00395 const xmlChar *elem, 00396 const xmlChar *name, 00397 const xmlChar *prefix); 00398 XMLPUBFUN xmlNotationPtr XMLCALL 00399 xmlGetDtdNotationDesc (xmlDtdPtr dtd, 00400 const xmlChar *name); 00401 XMLPUBFUN xmlElementPtr XMLCALL 00402 xmlGetDtdQElementDesc (xmlDtdPtr dtd, 00403 const xmlChar *name, 00404 const xmlChar *prefix); 00405 XMLPUBFUN xmlElementPtr XMLCALL 00406 xmlGetDtdElementDesc (xmlDtdPtr dtd, 00407 const xmlChar *name); 00408 00409 #ifdef LIBXML_VALID_ENABLED 00410 00411 XMLPUBFUN int XMLCALL 00412 xmlValidGetPotentialChildren(xmlElementContent *ctree, 00413 const xmlChar **names, 00414 int *len, 00415 int max); 00416 00417 XMLPUBFUN int XMLCALL 00418 xmlValidGetValidElements(xmlNode *prev, 00419 xmlNode *next, 00420 const xmlChar **names, 00421 int max); 00422 XMLPUBFUN int XMLCALL 00423 xmlValidateNameValue (const xmlChar *value); 00424 XMLPUBFUN int XMLCALL 00425 xmlValidateNamesValue (const xmlChar *value); 00426 XMLPUBFUN int XMLCALL 00427 xmlValidateNmtokenValue (const xmlChar *value); 00428 XMLPUBFUN int XMLCALL 00429 xmlValidateNmtokensValue(const xmlChar *value); 00430 00431 #ifdef LIBXML_REGEXP_ENABLED 00432 /* 00433 * Validation based on the regexp support 00434 */ 00435 XMLPUBFUN int XMLCALL 00436 xmlValidBuildContentModel(xmlValidCtxtPtr ctxt, 00437 xmlElementPtr elem); 00438 00439 XMLPUBFUN int XMLCALL 00440 xmlValidatePushElement (xmlValidCtxtPtr ctxt, 00441 xmlDocPtr doc, 00442 xmlNodePtr elem, 00443 const xmlChar *qname); 00444 XMLPUBFUN int XMLCALL 00445 xmlValidatePushCData (xmlValidCtxtPtr ctxt, 00446 const xmlChar *data, 00447 int len); 00448 XMLPUBFUN int XMLCALL 00449 xmlValidatePopElement (xmlValidCtxtPtr ctxt, 00450 xmlDocPtr doc, 00451 xmlNodePtr elem, 00452 const xmlChar *qname); 00453 #endif /* LIBXML_REGEXP_ENABLED */ 00454 #endif /* LIBXML_VALID_ENABLED */ 00455 #ifdef __cplusplus 00456 } 00457 #endif 00458 #endif /* __XML_VALID_H__ */