Path: blob/master/venv/Lib/site-packages/lxml/includes/libxml/valid.h
811 views
/*1* Summary: The DTD validation2* Description: API for the DTD handling and the validity checking3*4* Copy: See Copyright for the status of this software.5*6* Author: Daniel Veillard7*/8910#ifndef __XML_VALID_H__11#define __XML_VALID_H__1213#include <libxml/xmlversion.h>14#include <libxml/xmlerror.h>15#include <libxml/tree.h>16#include <libxml/list.h>17#include <libxml/xmlautomata.h>18#include <libxml/xmlregexp.h>1920#ifdef __cplusplus21extern "C" {22#endif2324/*25* Validation state added for non-determinist content model.26*/27typedef struct _xmlValidState xmlValidState;28typedef xmlValidState *xmlValidStatePtr;2930/**31* xmlValidityErrorFunc:32* @ctx: usually an xmlValidCtxtPtr to a validity error context,33* but comes from ctxt->userData (which normally contains such34* a pointer); ctxt->userData can be changed by the user.35* @msg: the string to format *printf like vararg36* @...: remaining arguments to the format37*38* Callback called when a validity error is found. This is a message39* oriented function similar to an *printf function.40*/41typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,42const char *msg,43...) LIBXML_ATTR_FORMAT(2,3);4445/**46* xmlValidityWarningFunc:47* @ctx: usually an xmlValidCtxtPtr to a validity error context,48* but comes from ctxt->userData (which normally contains such49* a pointer); ctxt->userData can be changed by the user.50* @msg: the string to format *printf like vararg51* @...: remaining arguments to the format52*53* Callback called when a validity warning is found. This is a message54* oriented function similar to an *printf function.55*/56typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx,57const char *msg,58...) LIBXML_ATTR_FORMAT(2,3);5960#ifdef IN_LIBXML61/**62* XML_CTXT_FINISH_DTD_0:63*64* Special value for finishDtd field when embedded in an xmlParserCtxt65*/66#define XML_CTXT_FINISH_DTD_0 0xabcd123467/**68* XML_CTXT_FINISH_DTD_1:69*70* Special value for finishDtd field when embedded in an xmlParserCtxt71*/72#define XML_CTXT_FINISH_DTD_1 0xabcd123573#endif7475/*76* xmlValidCtxt:77* An xmlValidCtxt is used for error reporting when validating.78*/79typedef struct _xmlValidCtxt xmlValidCtxt;80typedef xmlValidCtxt *xmlValidCtxtPtr;81struct _xmlValidCtxt {82void *userData; /* user specific data block */83xmlValidityErrorFunc error; /* the callback in case of errors */84xmlValidityWarningFunc warning; /* the callback in case of warning */8586/* Node analysis stack used when validating within entities */87xmlNodePtr node; /* Current parsed Node */88int nodeNr; /* Depth of the parsing stack */89int nodeMax; /* Max depth of the parsing stack */90xmlNodePtr *nodeTab; /* array of nodes */9192unsigned int finishDtd; /* finished validating the Dtd ? */93xmlDocPtr doc; /* the document */94int valid; /* temporary validity check result */9596/* state state used for non-determinist content validation */97xmlValidState *vstate; /* current state */98int vstateNr; /* Depth of the validation stack */99int vstateMax; /* Max depth of the validation stack */100xmlValidState *vstateTab; /* array of validation states */101102#ifdef LIBXML_REGEXP_ENABLED103xmlAutomataPtr am; /* the automata */104xmlAutomataStatePtr state; /* used to build the automata */105#else106void *am;107void *state;108#endif109};110111/*112* ALL notation declarations are stored in a table.113* There is one table per DTD.114*/115116typedef struct _xmlHashTable xmlNotationTable;117typedef xmlNotationTable *xmlNotationTablePtr;118119/*120* ALL element declarations are stored in a table.121* There is one table per DTD.122*/123124typedef struct _xmlHashTable xmlElementTable;125typedef xmlElementTable *xmlElementTablePtr;126127/*128* ALL attribute declarations are stored in a table.129* There is one table per DTD.130*/131132typedef struct _xmlHashTable xmlAttributeTable;133typedef xmlAttributeTable *xmlAttributeTablePtr;134135/*136* ALL IDs attributes are stored in a table.137* There is one table per document.138*/139140typedef struct _xmlHashTable xmlIDTable;141typedef xmlIDTable *xmlIDTablePtr;142143/*144* ALL Refs attributes are stored in a table.145* There is one table per document.146*/147148typedef struct _xmlHashTable xmlRefTable;149typedef xmlRefTable *xmlRefTablePtr;150151/* Notation */152XMLPUBFUN xmlNotationPtr XMLCALL153xmlAddNotationDecl (xmlValidCtxtPtr ctxt,154xmlDtdPtr dtd,155const xmlChar *name,156const xmlChar *PublicID,157const xmlChar *SystemID);158#ifdef LIBXML_TREE_ENABLED159XMLPUBFUN xmlNotationTablePtr XMLCALL160xmlCopyNotationTable (xmlNotationTablePtr table);161#endif /* LIBXML_TREE_ENABLED */162XMLPUBFUN void XMLCALL163xmlFreeNotationTable (xmlNotationTablePtr table);164#ifdef LIBXML_OUTPUT_ENABLED165XMLPUBFUN void XMLCALL166xmlDumpNotationDecl (xmlBufferPtr buf,167xmlNotationPtr nota);168XMLPUBFUN void XMLCALL169xmlDumpNotationTable (xmlBufferPtr buf,170xmlNotationTablePtr table);171#endif /* LIBXML_OUTPUT_ENABLED */172173/* Element Content */174/* the non Doc version are being deprecated */175XMLPUBFUN xmlElementContentPtr XMLCALL176xmlNewElementContent (const xmlChar *name,177xmlElementContentType type);178XMLPUBFUN xmlElementContentPtr XMLCALL179xmlCopyElementContent (xmlElementContentPtr content);180XMLPUBFUN void XMLCALL181xmlFreeElementContent (xmlElementContentPtr cur);182/* the new versions with doc argument */183XMLPUBFUN xmlElementContentPtr XMLCALL184xmlNewDocElementContent (xmlDocPtr doc,185const xmlChar *name,186xmlElementContentType type);187XMLPUBFUN xmlElementContentPtr XMLCALL188xmlCopyDocElementContent(xmlDocPtr doc,189xmlElementContentPtr content);190XMLPUBFUN void XMLCALL191xmlFreeDocElementContent(xmlDocPtr doc,192xmlElementContentPtr cur);193XMLPUBFUN void XMLCALL194xmlSnprintfElementContent(char *buf,195int size,196xmlElementContentPtr content,197int englob);198#ifdef LIBXML_OUTPUT_ENABLED199/* DEPRECATED */200XMLPUBFUN void XMLCALL201xmlSprintfElementContent(char *buf,202xmlElementContentPtr content,203int englob);204#endif /* LIBXML_OUTPUT_ENABLED */205/* DEPRECATED */206207/* Element */208XMLPUBFUN xmlElementPtr XMLCALL209xmlAddElementDecl (xmlValidCtxtPtr ctxt,210xmlDtdPtr dtd,211const xmlChar *name,212xmlElementTypeVal type,213xmlElementContentPtr content);214#ifdef LIBXML_TREE_ENABLED215XMLPUBFUN xmlElementTablePtr XMLCALL216xmlCopyElementTable (xmlElementTablePtr table);217#endif /* LIBXML_TREE_ENABLED */218XMLPUBFUN void XMLCALL219xmlFreeElementTable (xmlElementTablePtr table);220#ifdef LIBXML_OUTPUT_ENABLED221XMLPUBFUN void XMLCALL222xmlDumpElementTable (xmlBufferPtr buf,223xmlElementTablePtr table);224XMLPUBFUN void XMLCALL225xmlDumpElementDecl (xmlBufferPtr buf,226xmlElementPtr elem);227#endif /* LIBXML_OUTPUT_ENABLED */228229/* Enumeration */230XMLPUBFUN xmlEnumerationPtr XMLCALL231xmlCreateEnumeration (const xmlChar *name);232XMLPUBFUN void XMLCALL233xmlFreeEnumeration (xmlEnumerationPtr cur);234#ifdef LIBXML_TREE_ENABLED235XMLPUBFUN xmlEnumerationPtr XMLCALL236xmlCopyEnumeration (xmlEnumerationPtr cur);237#endif /* LIBXML_TREE_ENABLED */238239/* Attribute */240XMLPUBFUN xmlAttributePtr XMLCALL241xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,242xmlDtdPtr dtd,243const xmlChar *elem,244const xmlChar *name,245const xmlChar *ns,246xmlAttributeType type,247xmlAttributeDefault def,248const xmlChar *defaultValue,249xmlEnumerationPtr tree);250#ifdef LIBXML_TREE_ENABLED251XMLPUBFUN xmlAttributeTablePtr XMLCALL252xmlCopyAttributeTable (xmlAttributeTablePtr table);253#endif /* LIBXML_TREE_ENABLED */254XMLPUBFUN void XMLCALL255xmlFreeAttributeTable (xmlAttributeTablePtr table);256#ifdef LIBXML_OUTPUT_ENABLED257XMLPUBFUN void XMLCALL258xmlDumpAttributeTable (xmlBufferPtr buf,259xmlAttributeTablePtr table);260XMLPUBFUN void XMLCALL261xmlDumpAttributeDecl (xmlBufferPtr buf,262xmlAttributePtr attr);263#endif /* LIBXML_OUTPUT_ENABLED */264265/* IDs */266XMLPUBFUN xmlIDPtr XMLCALL267xmlAddID (xmlValidCtxtPtr ctxt,268xmlDocPtr doc,269const xmlChar *value,270xmlAttrPtr attr);271XMLPUBFUN void XMLCALL272xmlFreeIDTable (xmlIDTablePtr table);273XMLPUBFUN xmlAttrPtr XMLCALL274xmlGetID (xmlDocPtr doc,275const xmlChar *ID);276XMLPUBFUN int XMLCALL277xmlIsID (xmlDocPtr doc,278xmlNodePtr elem,279xmlAttrPtr attr);280XMLPUBFUN int XMLCALL281xmlRemoveID (xmlDocPtr doc,282xmlAttrPtr attr);283284/* IDREFs */285XMLPUBFUN xmlRefPtr XMLCALL286xmlAddRef (xmlValidCtxtPtr ctxt,287xmlDocPtr doc,288const xmlChar *value,289xmlAttrPtr attr);290XMLPUBFUN void XMLCALL291xmlFreeRefTable (xmlRefTablePtr table);292XMLPUBFUN int XMLCALL293xmlIsRef (xmlDocPtr doc,294xmlNodePtr elem,295xmlAttrPtr attr);296XMLPUBFUN int XMLCALL297xmlRemoveRef (xmlDocPtr doc,298xmlAttrPtr attr);299XMLPUBFUN xmlListPtr XMLCALL300xmlGetRefs (xmlDocPtr doc,301const xmlChar *ID);302303/**304* The public function calls related to validity checking.305*/306#ifdef LIBXML_VALID_ENABLED307/* Allocate/Release Validation Contexts */308XMLPUBFUN xmlValidCtxtPtr XMLCALL309xmlNewValidCtxt(void);310XMLPUBFUN void XMLCALL311xmlFreeValidCtxt(xmlValidCtxtPtr);312313XMLPUBFUN int XMLCALL314xmlValidateRoot (xmlValidCtxtPtr ctxt,315xmlDocPtr doc);316XMLPUBFUN int XMLCALL317xmlValidateElementDecl (xmlValidCtxtPtr ctxt,318xmlDocPtr doc,319xmlElementPtr elem);320XMLPUBFUN xmlChar * XMLCALL321xmlValidNormalizeAttributeValue(xmlDocPtr doc,322xmlNodePtr elem,323const xmlChar *name,324const xmlChar *value);325XMLPUBFUN xmlChar * XMLCALL326xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,327xmlDocPtr doc,328xmlNodePtr elem,329const xmlChar *name,330const xmlChar *value);331XMLPUBFUN int XMLCALL332xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,333xmlDocPtr doc,334xmlAttributePtr attr);335XMLPUBFUN int XMLCALL336xmlValidateAttributeValue(xmlAttributeType type,337const xmlChar *value);338XMLPUBFUN int XMLCALL339xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,340xmlDocPtr doc,341xmlNotationPtr nota);342XMLPUBFUN int XMLCALL343xmlValidateDtd (xmlValidCtxtPtr ctxt,344xmlDocPtr doc,345xmlDtdPtr dtd);346XMLPUBFUN int XMLCALL347xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,348xmlDocPtr doc);349XMLPUBFUN int XMLCALL350xmlValidateDocument (xmlValidCtxtPtr ctxt,351xmlDocPtr doc);352XMLPUBFUN int XMLCALL353xmlValidateElement (xmlValidCtxtPtr ctxt,354xmlDocPtr doc,355xmlNodePtr elem);356XMLPUBFUN int XMLCALL357xmlValidateOneElement (xmlValidCtxtPtr ctxt,358xmlDocPtr doc,359xmlNodePtr elem);360XMLPUBFUN int XMLCALL361xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,362xmlDocPtr doc,363xmlNodePtr elem,364xmlAttrPtr attr,365const xmlChar *value);366XMLPUBFUN int XMLCALL367xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,368xmlDocPtr doc,369xmlNodePtr elem,370const xmlChar *prefix,371xmlNsPtr ns,372const xmlChar *value);373XMLPUBFUN int XMLCALL374xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,375xmlDocPtr doc);376#endif /* LIBXML_VALID_ENABLED */377378#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)379XMLPUBFUN int XMLCALL380xmlValidateNotationUse (xmlValidCtxtPtr ctxt,381xmlDocPtr doc,382const xmlChar *notationName);383#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */384385XMLPUBFUN int XMLCALL386xmlIsMixedElement (xmlDocPtr doc,387const xmlChar *name);388XMLPUBFUN xmlAttributePtr XMLCALL389xmlGetDtdAttrDesc (xmlDtdPtr dtd,390const xmlChar *elem,391const xmlChar *name);392XMLPUBFUN xmlAttributePtr XMLCALL393xmlGetDtdQAttrDesc (xmlDtdPtr dtd,394const xmlChar *elem,395const xmlChar *name,396const xmlChar *prefix);397XMLPUBFUN xmlNotationPtr XMLCALL398xmlGetDtdNotationDesc (xmlDtdPtr dtd,399const xmlChar *name);400XMLPUBFUN xmlElementPtr XMLCALL401xmlGetDtdQElementDesc (xmlDtdPtr dtd,402const xmlChar *name,403const xmlChar *prefix);404XMLPUBFUN xmlElementPtr XMLCALL405xmlGetDtdElementDesc (xmlDtdPtr dtd,406const xmlChar *name);407408#ifdef LIBXML_VALID_ENABLED409410XMLPUBFUN int XMLCALL411xmlValidGetPotentialChildren(xmlElementContent *ctree,412const xmlChar **names,413int *len,414int max);415416XMLPUBFUN int XMLCALL417xmlValidGetValidElements(xmlNode *prev,418xmlNode *next,419const xmlChar **names,420int max);421XMLPUBFUN int XMLCALL422xmlValidateNameValue (const xmlChar *value);423XMLPUBFUN int XMLCALL424xmlValidateNamesValue (const xmlChar *value);425XMLPUBFUN int XMLCALL426xmlValidateNmtokenValue (const xmlChar *value);427XMLPUBFUN int XMLCALL428xmlValidateNmtokensValue(const xmlChar *value);429430#ifdef LIBXML_REGEXP_ENABLED431/*432* Validation based on the regexp support433*/434XMLPUBFUN int XMLCALL435xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,436xmlElementPtr elem);437438XMLPUBFUN int XMLCALL439xmlValidatePushElement (xmlValidCtxtPtr ctxt,440xmlDocPtr doc,441xmlNodePtr elem,442const xmlChar *qname);443XMLPUBFUN int XMLCALL444xmlValidatePushCData (xmlValidCtxtPtr ctxt,445const xmlChar *data,446int len);447XMLPUBFUN int XMLCALL448xmlValidatePopElement (xmlValidCtxtPtr ctxt,449xmlDocPtr doc,450xmlNodePtr elem,451const xmlChar *qname);452#endif /* LIBXML_REGEXP_ENABLED */453#endif /* LIBXML_VALID_ENABLED */454#ifdef __cplusplus455}456#endif457#endif /* __XML_VALID_H__ */458459460