valid.h

00001 /*
00002 
00003  * Summary: The DTD validation
00004 
00005  * Description: API for the DTD handling and the validity checking
00006 
00007  *
00008 
00009  * Copy: See Copyright for the status of this software.
00010 
00011  *
00012 
00013  * Author: Daniel Veillard
00014 
00015  */
00016 
00017 
00018 
00019 
00020 
00021 #ifndef __XML_VALID_H__
00022 
00023 #define __XML_VALID_H__
00024 
00025 
00026 
00027 #include <libxml/xmlversion.h>
00028 
00029 #include <libxml/xmlerror.h>
00030 
00031 #include <libxml/tree.h>
00032 
00033 #include <libxml/list.h>
00034 
00035 #include <libxml/xmlautomata.h>
00036 
00037 #include <libxml/xmlregexp.h>
00038 
00039 
00040 
00041 #ifdef __cplusplus
00042 
00043 extern "C" {
00044 
00045 #endif
00046 
00047 
00048 
00049 /*
00050 
00051  * Validation state added for non-determinist content model.
00052 
00053  */
00054 
00055 typedef struct _xmlValidState xmlValidState;
00056 
00057 typedef xmlValidState *xmlValidStatePtr;
00058 
00059 
00060 
00083 typedef void (*xmlValidityErrorFunc) (void *ctx,
00084 
00085                              const char *msg,
00086 
00087                              ...);
00088 
00089 
00090 
00113 typedef void (*xmlValidityWarningFunc) (void *ctx,
00114 
00115                                const char *msg,
00116 
00117                                ...);
00118 
00119 
00120 
00121 #ifdef IN_LIBXML
00122 
00133 #define XML_CTXT_FINISH_DTD_0 0xabcd1234
00134 
00145 #define XML_CTXT_FINISH_DTD_1 0xabcd1235
00146 
00147 #endif
00148 
00149 
00150 
00151 /*
00152 
00153  * xmlValidCtxt:
00154 
00155  * An xmlValidCtxt is used for error reporting when validating.
00156 
00157  */
00158 
00159 typedef struct _xmlValidCtxt xmlValidCtxt;
00160 
00161 typedef xmlValidCtxt *xmlValidCtxtPtr;
00162 
00163 struct _xmlValidCtxt {
00164 
00165     void *userData;                     /* user specific data block */
00166 
00167     xmlValidityErrorFunc error;         /* the callback in case of errors */
00168 
00169     xmlValidityWarningFunc warning;     /* the callback in case of warning */
00170 
00171 
00172 
00173     /* Node analysis stack used when validating within entities */
00174 
00175     xmlNodePtr         node;          /* Current parsed Node */
00176 
00177     int                nodeNr;        /* Depth of the parsing stack */
00178 
00179     int                nodeMax;       /* Max depth of the parsing stack */
00180 
00181     xmlNodePtr        *nodeTab;       /* array of nodes */
00182 
00183 
00184 
00185     unsigned int     finishDtd;       /* finished validating the Dtd ? */
00186 
00187     xmlDocPtr              doc;       /* the document */
00188 
00189     int                  valid;       /* temporary validity check result */
00190 
00191 
00192 
00193     /* state state used for non-determinist content validation */
00194 
00195     xmlValidState     *vstate;        /* current state */
00196 
00197     int                vstateNr;      /* Depth of the validation stack */
00198 
00199     int                vstateMax;     /* Max depth of the validation stack */
00200 
00201     xmlValidState     *vstateTab;     /* array of validation states */
00202 
00203 
00204 
00205 #ifdef LIBXML_REGEXP_ENABLED
00206 
00207     xmlAutomataPtr            am;     /* the automata */
00208 
00209     xmlAutomataStatePtr    state;     /* used to build the automata */
00210 
00211 #else
00212 
00213     void                     *am;
00214 
00215     void                  *state;
00216 
00217 #endif
00218 
00219 };
00220 
00221 
00222 
00223 /*
00224 
00225  * ALL notation declarations are stored in a table.
00226 
00227  * There is one table per DTD.
00228 
00229  */
00230 
00231 
00232 
00233 typedef struct _xmlHashTable xmlNotationTable;
00234 
00235 typedef xmlNotationTable *xmlNotationTablePtr;
00236 
00237 
00238 
00239 /*
00240 
00241  * ALL element declarations are stored in a table.
00242 
00243  * There is one table per DTD.
00244 
00245  */
00246 
00247 
00248 
00249 typedef struct _xmlHashTable xmlElementTable;
00250 
00251 typedef xmlElementTable *xmlElementTablePtr;
00252 
00253 
00254 
00255 /*
00256 
00257  * ALL attribute declarations are stored in a table.
00258 
00259  * There is one table per DTD.
00260 
00261  */
00262 
00263 
00264 
00265 typedef struct _xmlHashTable xmlAttributeTable;
00266 
00267 typedef xmlAttributeTable *xmlAttributeTablePtr;
00268 
00269 
00270 
00271 /*
00272 
00273  * ALL IDs attributes are stored in a table.
00274 
00275  * There is one table per document.
00276 
00277  */
00278 
00279 
00280 
00281 typedef struct _xmlHashTable xmlIDTable;
00282 
00283 typedef xmlIDTable *xmlIDTablePtr;
00284 
00285 
00286 
00287 /*
00288 
00289  * ALL Refs attributes are stored in a table.
00290 
00291  * There is one table per document.
00292 
00293  */
00294 
00295 
00296 
00297 typedef struct _xmlHashTable xmlRefTable;
00298 
00299 typedef xmlRefTable *xmlRefTablePtr;
00300 
00301 
00302 
00303 /* Notation */
00304 
00305 XMLPUBFUN xmlNotationPtr XMLCALL            
00306 
00307                 xmlAddNotationDecl      (xmlValidCtxtPtr ctxt,
00308 
00309                                          xmlDtdPtr dtd,
00310 
00311                                          const xmlChar *name,
00312 
00313                                          const xmlChar *PublicID,
00314 
00315                                          const xmlChar *SystemID);
00316 
00317 #ifdef LIBXML_TREE_ENABLED
00318 
00319 XMLPUBFUN xmlNotationTablePtr XMLCALL 
00320 
00321                 xmlCopyNotationTable    (xmlNotationTablePtr table);
00322 
00323 #endif /* LIBXML_TREE_ENABLED */
00324 
00325 XMLPUBFUN void XMLCALL              
00326 
00327                 xmlFreeNotationTable    (xmlNotationTablePtr table);
00328 
00329 #ifdef LIBXML_OUTPUT_ENABLED
00330 
00331 XMLPUBFUN void XMLCALL              
00332 
00333                 xmlDumpNotationDecl     (xmlBufferPtr buf,
00334 
00335                                          xmlNotationPtr nota);
00336 
00337 XMLPUBFUN void XMLCALL              
00338 
00339                 xmlDumpNotationTable    (xmlBufferPtr buf,
00340 
00341                                          xmlNotationTablePtr table);
00342 
00343 #endif /* LIBXML_OUTPUT_ENABLED */
00344 
00345 
00346 
00347 /* Element Content */
00348 
00349 XMLPUBFUN xmlElementContentPtr XMLCALL 
00350 
00351                 xmlNewElementContent    (const xmlChar *name,
00352 
00353                                          xmlElementContentType type);
00354 
00355 XMLPUBFUN xmlElementContentPtr XMLCALL 
00356 
00357                 xmlCopyElementContent   (xmlElementContentPtr content);
00358 
00359 XMLPUBFUN void XMLCALL               
00360 
00361                 xmlFreeElementContent   (xmlElementContentPtr cur);
00362 
00363 XMLPUBFUN void XMLCALL               
00364 
00365                 xmlSnprintfElementContent(char *buf,
00366 
00367                                          int size,
00368 
00369                                          xmlElementContentPtr content,
00370 
00371                                          int glob);
00372 
00373 #ifdef LIBXML_OUTPUT_ENABLED
00374 
00375 /* DEPRECATED */
00376 
00377 XMLPUBFUN void XMLCALL               
00378 
00379                 xmlSprintfElementContent(char *buf,
00380 
00381                                          xmlElementContentPtr content,
00382 
00383                                          int glob);
00384 
00385 #endif /* LIBXML_OUTPUT_ENABLED */
00386 
00387 /* DEPRECATED */
00388 
00389 
00390 
00391 /* Element */
00392 
00393 XMLPUBFUN xmlElementPtr XMLCALL    
00394 
00395                 xmlAddElementDecl       (xmlValidCtxtPtr ctxt,
00396 
00397                                          xmlDtdPtr dtd,
00398 
00399                                          const xmlChar *name,
00400 
00401                                          xmlElementTypeVal type,
00402 
00403                                          xmlElementContentPtr content);
00404 
00405 #ifdef LIBXML_TREE_ENABLED
00406 
00407 XMLPUBFUN xmlElementTablePtr XMLCALL 
00408 
00409                 xmlCopyElementTable     (xmlElementTablePtr table);
00410 
00411 #endif /* LIBXML_TREE_ENABLED */
00412 
00413 XMLPUBFUN void XMLCALL             
00414 
00415                 xmlFreeElementTable     (xmlElementTablePtr table);
00416 
00417 #ifdef LIBXML_OUTPUT_ENABLED
00418 
00419 XMLPUBFUN void XMLCALL             
00420 
00421                 xmlDumpElementTable     (xmlBufferPtr buf,
00422 
00423                                          xmlElementTablePtr table);
00424 
00425 XMLPUBFUN void XMLCALL             
00426 
00427                 xmlDumpElementDecl      (xmlBufferPtr buf,
00428 
00429                                          xmlElementPtr elem);
00430 
00431 #endif /* LIBXML_OUTPUT_ENABLED */
00432 
00433 
00434 
00435 /* Enumeration */
00436 
00437 XMLPUBFUN xmlEnumerationPtr XMLCALL 
00438 
00439                 xmlCreateEnumeration    (const xmlChar *name);
00440 
00441 XMLPUBFUN void XMLCALL             
00442 
00443                 xmlFreeEnumeration      (xmlEnumerationPtr cur);
00444 
00445 #ifdef LIBXML_TREE_ENABLED
00446 
00447 XMLPUBFUN xmlEnumerationPtr XMLCALL  
00448 
00449                 xmlCopyEnumeration      (xmlEnumerationPtr cur);
00450 
00451 #endif /* LIBXML_TREE_ENABLED */
00452 
00453 
00454 
00455 /* Attribute */
00456 
00457 XMLPUBFUN xmlAttributePtr XMLCALL           
00458 
00459                 xmlAddAttributeDecl     (xmlValidCtxtPtr ctxt,
00460 
00461                                          xmlDtdPtr dtd,
00462 
00463                                          const xmlChar *elem,
00464 
00465                                          const xmlChar *name,
00466 
00467                                          const xmlChar *ns,
00468 
00469                                          xmlAttributeType type,
00470 
00471                                          xmlAttributeDefault def,
00472 
00473                                          const xmlChar *defaultValue,
00474 
00475                                          xmlEnumerationPtr tree);
00476 
00477 #ifdef LIBXML_TREE_ENABLED
00478 
00479 XMLPUBFUN xmlAttributeTablePtr XMLCALL 
00480 
00481                 xmlCopyAttributeTable  (xmlAttributeTablePtr table);
00482 
00483 #endif /* LIBXML_TREE_ENABLED */
00484 
00485 XMLPUBFUN void XMLCALL               
00486 
00487                 xmlFreeAttributeTable  (xmlAttributeTablePtr table);
00488 
00489 #ifdef LIBXML_OUTPUT_ENABLED
00490 
00491 XMLPUBFUN void XMLCALL               
00492 
00493                 xmlDumpAttributeTable  (xmlBufferPtr buf,
00494 
00495                                         xmlAttributeTablePtr table);
00496 
00497 XMLPUBFUN void XMLCALL               
00498 
00499                 xmlDumpAttributeDecl   (xmlBufferPtr buf,
00500 
00501                                         xmlAttributePtr attr);
00502 
00503 #endif /* LIBXML_OUTPUT_ENABLED */
00504 
00505 
00506 
00507 /* IDs */
00508 
00509 XMLPUBFUN xmlIDPtr XMLCALL      
00510 
00511                 xmlAddID               (xmlValidCtxtPtr ctxt,
00512 
00513                                         xmlDocPtr doc,
00514 
00515                                         const xmlChar *value,
00516 
00517                                         xmlAttrPtr attr);
00518 
00519 XMLPUBFUN void XMLCALL          
00520 
00521                 xmlFreeIDTable         (xmlIDTablePtr table);
00522 
00523 XMLPUBFUN xmlAttrPtr XMLCALL    
00524 
00525                 xmlGetID               (xmlDocPtr doc,
00526 
00527                                         const xmlChar *ID);
00528 
00529 XMLPUBFUN int XMLCALL           
00530 
00531                 xmlIsID                (xmlDocPtr doc,
00532 
00533                                         xmlNodePtr elem,
00534 
00535                                         xmlAttrPtr attr);
00536 
00537 XMLPUBFUN int XMLCALL           
00538 
00539                 xmlRemoveID            (xmlDocPtr doc, 
00540 
00541                                         xmlAttrPtr attr);
00542 
00543 
00544 
00545 /* IDREFs */
00546 
00547 XMLPUBFUN xmlRefPtr XMLCALL     
00548 
00549                 xmlAddRef              (xmlValidCtxtPtr ctxt,
00550 
00551                                         xmlDocPtr doc,
00552 
00553                                         const xmlChar *value,
00554 
00555                                         xmlAttrPtr attr);
00556 
00557 XMLPUBFUN void XMLCALL          
00558 
00559                 xmlFreeRefTable        (xmlRefTablePtr table);
00560 
00561 XMLPUBFUN int XMLCALL           
00562 
00563                 xmlIsRef               (xmlDocPtr doc,
00564 
00565                                         xmlNodePtr elem,
00566 
00567                                         xmlAttrPtr attr);
00568 
00569 XMLPUBFUN int XMLCALL           
00570 
00571                 xmlRemoveRef           (xmlDocPtr doc, 
00572 
00573                                         xmlAttrPtr attr);
00574 
00575 XMLPUBFUN xmlListPtr XMLCALL    
00576 
00577                 xmlGetRefs             (xmlDocPtr doc,
00578 
00579                                         const xmlChar *ID);
00580 
00581 
00582 
00589 #ifdef LIBXML_VALID_ENABLED
00590 
00591 /* Allocate/Release Validation Contexts */
00592 
00593 XMLPUBFUN xmlValidCtxtPtr XMLCALL           
00594 
00595                 xmlNewValidCtxt(void);
00596 
00597 XMLPUBFUN void XMLCALL              
00598 
00599                 xmlFreeValidCtxt(xmlValidCtxtPtr);
00600 
00601 
00602 
00603 XMLPUBFUN int XMLCALL           
00604 
00605                 xmlValidateRoot         (xmlValidCtxtPtr ctxt,
00606 
00607                                          xmlDocPtr doc);
00608 
00609 XMLPUBFUN int XMLCALL           
00610 
00611                 xmlValidateElementDecl  (xmlValidCtxtPtr ctxt,
00612 
00613                                          xmlDocPtr doc,
00614 
00615                                          xmlElementPtr elem);
00616 
00617 XMLPUBFUN xmlChar * XMLCALL     
00618 
00619                 xmlValidNormalizeAttributeValue(xmlDocPtr doc,
00620 
00621                                          xmlNodePtr elem,
00622 
00623                                          const xmlChar *name,
00624 
00625                                          const xmlChar *value);
00626 
00627 XMLPUBFUN xmlChar * XMLCALL     
00628 
00629                 xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
00630 
00631                                          xmlDocPtr doc,
00632 
00633                                          xmlNodePtr elem,
00634 
00635                                          const xmlChar *name,
00636 
00637                                          const xmlChar *value);
00638 
00639 XMLPUBFUN int XMLCALL           
00640 
00641                 xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
00642 
00643                                          xmlDocPtr doc,
00644 
00645                                          xmlAttributePtr attr);
00646 
00647 XMLPUBFUN int XMLCALL           
00648 
00649                 xmlValidateAttributeValue(xmlAttributeType type,
00650 
00651                                          const xmlChar *value);
00652 
00653 XMLPUBFUN int XMLCALL           
00654 
00655                 xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
00656 
00657                                          xmlDocPtr doc,
00658 
00659                                          xmlNotationPtr nota);
00660 
00661 XMLPUBFUN int XMLCALL           
00662 
00663                 xmlValidateDtd          (xmlValidCtxtPtr ctxt,
00664 
00665                                          xmlDocPtr doc,
00666 
00667                                          xmlDtdPtr dtd);
00668 
00669 XMLPUBFUN int XMLCALL           
00670 
00671                 xmlValidateDtdFinal     (xmlValidCtxtPtr ctxt,
00672 
00673                                          xmlDocPtr doc);
00674 
00675 XMLPUBFUN int XMLCALL           
00676 
00677                 xmlValidateDocument     (xmlValidCtxtPtr ctxt,
00678 
00679                                          xmlDocPtr doc);
00680 
00681 XMLPUBFUN int XMLCALL           
00682 
00683                 xmlValidateElement      (xmlValidCtxtPtr ctxt,
00684 
00685                                          xmlDocPtr doc,
00686 
00687                                          xmlNodePtr elem);
00688 
00689 XMLPUBFUN int XMLCALL           
00690 
00691                 xmlValidateOneElement   (xmlValidCtxtPtr ctxt,
00692 
00693                                          xmlDocPtr doc,
00694 
00695                                          xmlNodePtr elem);
00696 
00697 XMLPUBFUN int XMLCALL   
00698 
00699                 xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
00700 
00701                                          xmlDocPtr doc,
00702 
00703                                          xmlNodePtr     elem,
00704 
00705                                          xmlAttrPtr attr,
00706 
00707                                          const xmlChar *value);
00708 
00709 XMLPUBFUN int XMLCALL           
00710 
00711                 xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
00712 
00713                                          xmlDocPtr doc,
00714 
00715                                          xmlNodePtr elem,
00716 
00717                                          const xmlChar *prefix,
00718 
00719                                          xmlNsPtr ns,
00720 
00721                                          const xmlChar *value);
00722 
00723 XMLPUBFUN int XMLCALL           
00724 
00725                 xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
00726 
00727                                          xmlDocPtr doc);
00728 
00729 #endif /* LIBXML_VALID_ENABLED */
00730 
00731 
00732 
00733 #if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
00734 
00735 XMLPUBFUN int XMLCALL           
00736 
00737                 xmlValidateNotationUse  (xmlValidCtxtPtr ctxt,
00738 
00739                                          xmlDocPtr doc,
00740 
00741                                          const xmlChar *notationName);
00742 
00743 #endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
00744 
00745 
00746 
00747 XMLPUBFUN int XMLCALL           
00748 
00749                 xmlIsMixedElement       (xmlDocPtr doc,
00750 
00751                                          const xmlChar *name);
00752 
00753 XMLPUBFUN xmlAttributePtr XMLCALL       
00754 
00755                 xmlGetDtdAttrDesc       (xmlDtdPtr dtd,
00756 
00757                                          const xmlChar *elem,
00758 
00759                                          const xmlChar *name);
00760 
00761 XMLPUBFUN xmlAttributePtr XMLCALL       
00762 
00763                 xmlGetDtdQAttrDesc      (xmlDtdPtr dtd,
00764 
00765                                          const xmlChar *elem,
00766 
00767                                          const xmlChar *name,
00768 
00769                                          const xmlChar *prefix);
00770 
00771 XMLPUBFUN xmlNotationPtr XMLCALL        
00772 
00773                 xmlGetDtdNotationDesc   (xmlDtdPtr dtd,
00774 
00775                                          const xmlChar *name);
00776 
00777 XMLPUBFUN xmlElementPtr XMLCALL 
00778 
00779                 xmlGetDtdQElementDesc   (xmlDtdPtr dtd,
00780 
00781                                          const xmlChar *name,
00782 
00783                                          const xmlChar *prefix);
00784 
00785 XMLPUBFUN xmlElementPtr XMLCALL 
00786 
00787                 xmlGetDtdElementDesc    (xmlDtdPtr dtd,
00788 
00789                                          const xmlChar *name);
00790 
00791 
00792 
00793 #ifdef LIBXML_VALID_ENABLED
00794 
00795 
00796 
00797 XMLPUBFUN int XMLCALL           
00798 
00799                 xmlValidGetPotentialChildren(xmlElementContent *ctree,
00800 
00801                                          const xmlChar **list,
00802 
00803                                          int *len,
00804 
00805                                          int max);
00806 
00807 
00808 
00809 XMLPUBFUN int XMLCALL           
00810 
00811                 xmlValidGetValidElements(xmlNode *prev,
00812 
00813                                          xmlNode *next,
00814 
00815                                          const xmlChar **names,
00816 
00817                                          int max);
00818 
00819 XMLPUBFUN int XMLCALL           
00820 
00821                 xmlValidateNameValue    (const xmlChar *value);
00822 
00823 XMLPUBFUN int XMLCALL           
00824 
00825                 xmlValidateNamesValue   (const xmlChar *value);
00826 
00827 XMLPUBFUN int XMLCALL           
00828 
00829                 xmlValidateNmtokenValue (const xmlChar *value);
00830 
00831 XMLPUBFUN int XMLCALL           
00832 
00833                 xmlValidateNmtokensValue(const xmlChar *value);
00834 
00835 
00836 
00837 #ifdef LIBXML_REGEXP_ENABLED
00838 
00839 /*
00840 
00841  * Validation based on the regexp support
00842 
00843  */
00844 
00845 XMLPUBFUN int XMLCALL           
00846 
00847                 xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
00848 
00849                                          xmlElementPtr elem);
00850 
00851 
00852 
00853 XMLPUBFUN int XMLCALL           
00854 
00855                 xmlValidatePushElement  (xmlValidCtxtPtr ctxt,
00856 
00857                                          xmlDocPtr doc,
00858 
00859                                          xmlNodePtr elem,
00860 
00861                                          const xmlChar *qname);
00862 
00863 XMLPUBFUN int XMLCALL           
00864 
00865                 xmlValidatePushCData    (xmlValidCtxtPtr ctxt,
00866 
00867                                          const xmlChar *data,
00868 
00869                                          int len);
00870 
00871 XMLPUBFUN int XMLCALL           
00872 
00873                 xmlValidatePopElement   (xmlValidCtxtPtr ctxt,
00874 
00875                                          xmlDocPtr doc,
00876 
00877                                          xmlNodePtr elem,
00878 
00879                                          const xmlChar *qname);
00880 
00881 #endif /* LIBXML_REGEXP_ENABLED */
00882 
00883 #endif /* LIBXML_VALID_ENABLED */
00884 
00885 #ifdef __cplusplus
00886 
00887 }
00888 
00889 #endif
00890 
00891 #endif /* __XML_VALID_H__ */
00892 

Generated on Wed Jul 26 13:30:46 2006 for XSB by  doxygen 1.4.5