Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:41:51

0001 /*
0002  * Summary: The DTD validation
0003  * Description: API for the DTD handling and the validity checking
0004  *
0005  * Copy: See Copyright for the status of this software.
0006  *
0007  * Author: Daniel Veillard
0008  */
0009 
0010 
0011 #ifndef __XML_VALID_H__
0012 #define __XML_VALID_H__
0013 
0014 /** DOC_DISABLE */
0015 #include <libxml/xmlversion.h>
0016 #include <libxml/xmlerror.h>
0017 #define XML_TREE_INTERNALS
0018 #include <libxml/tree.h>
0019 #undef XML_TREE_INTERNALS
0020 #include <libxml/list.h>
0021 #include <libxml/xmlautomata.h>
0022 #include <libxml/xmlregexp.h>
0023 /** DOC_ENABLE */
0024 
0025 #ifdef __cplusplus
0026 extern "C" {
0027 #endif
0028 
0029 /*
0030  * Validation state added for non-determinist content model.
0031  */
0032 typedef struct _xmlValidState xmlValidState;
0033 typedef xmlValidState *xmlValidStatePtr;
0034 
0035 /**
0036  * xmlValidityErrorFunc:
0037  * @ctx:  usually an xmlValidCtxtPtr to a validity error context,
0038  *        but comes from ctxt->userData (which normally contains such
0039  *        a pointer); ctxt->userData can be changed by the user.
0040  * @msg:  the string to format *printf like vararg
0041  * @...:  remaining arguments to the format
0042  *
0043  * Callback called when a validity error is found. This is a message
0044  * oriented function similar to an *printf function.
0045  */
0046 typedef void (*xmlValidityErrorFunc) (void *ctx,
0047                  const char *msg,
0048                  ...) LIBXML_ATTR_FORMAT(2,3);
0049 
0050 /**
0051  * xmlValidityWarningFunc:
0052  * @ctx:  usually an xmlValidCtxtPtr to a validity error context,
0053  *        but comes from ctxt->userData (which normally contains such
0054  *        a pointer); ctxt->userData can be changed by the user.
0055  * @msg:  the string to format *printf like vararg
0056  * @...:  remaining arguments to the format
0057  *
0058  * Callback called when a validity warning is found. This is a message
0059  * oriented function similar to an *printf function.
0060  */
0061 typedef void (*xmlValidityWarningFunc) (void *ctx,
0062                    const char *msg,
0063                    ...) LIBXML_ATTR_FORMAT(2,3);
0064 
0065 /*
0066  * xmlValidCtxt:
0067  * An xmlValidCtxt is used for error reporting when validating.
0068  */
0069 typedef struct _xmlValidCtxt xmlValidCtxt;
0070 typedef xmlValidCtxt *xmlValidCtxtPtr;
0071 struct _xmlValidCtxt {
0072     void *userData;         /* user specific data block */
0073     xmlValidityErrorFunc error;     /* the callback in case of errors */
0074     xmlValidityWarningFunc warning; /* the callback in case of warning */
0075 
0076     /* Node analysis stack used when validating within entities */
0077     xmlNodePtr         node;          /* Current parsed Node */
0078     int                nodeNr;        /* Depth of the parsing stack */
0079     int                nodeMax;       /* Max depth of the parsing stack */
0080     xmlNodePtr        *nodeTab;       /* array of nodes */
0081 
0082     unsigned int         flags;       /* internal flags */
0083     xmlDocPtr              doc;       /* the document */
0084     int                  valid;       /* temporary validity check result */
0085 
0086     /* state state used for non-determinist content validation */
0087     xmlValidState     *vstate;        /* current state */
0088     int                vstateNr;      /* Depth of the validation stack */
0089     int                vstateMax;     /* Max depth of the validation stack */
0090     xmlValidState     *vstateTab;     /* array of validation states */
0091 
0092 #ifdef LIBXML_REGEXP_ENABLED
0093     xmlAutomataPtr            am;     /* the automata */
0094     xmlAutomataStatePtr    state;     /* used to build the automata */
0095 #else
0096     void                     *am;
0097     void                  *state;
0098 #endif
0099 };
0100 
0101 /*
0102  * ALL notation declarations are stored in a table.
0103  * There is one table per DTD.
0104  */
0105 
0106 typedef struct _xmlHashTable xmlNotationTable;
0107 typedef xmlNotationTable *xmlNotationTablePtr;
0108 
0109 /*
0110  * ALL element declarations are stored in a table.
0111  * There is one table per DTD.
0112  */
0113 
0114 typedef struct _xmlHashTable xmlElementTable;
0115 typedef xmlElementTable *xmlElementTablePtr;
0116 
0117 /*
0118  * ALL attribute declarations are stored in a table.
0119  * There is one table per DTD.
0120  */
0121 
0122 typedef struct _xmlHashTable xmlAttributeTable;
0123 typedef xmlAttributeTable *xmlAttributeTablePtr;
0124 
0125 /*
0126  * ALL IDs attributes are stored in a table.
0127  * There is one table per document.
0128  */
0129 
0130 typedef struct _xmlHashTable xmlIDTable;
0131 typedef xmlIDTable *xmlIDTablePtr;
0132 
0133 /*
0134  * ALL Refs attributes are stored in a table.
0135  * There is one table per document.
0136  */
0137 
0138 typedef struct _xmlHashTable xmlRefTable;
0139 typedef xmlRefTable *xmlRefTablePtr;
0140 
0141 /* Notation */
0142 XMLPUBFUN xmlNotationPtr
0143         xmlAddNotationDecl  (xmlValidCtxtPtr ctxt,
0144                      xmlDtdPtr dtd,
0145                      const xmlChar *name,
0146                      const xmlChar *PublicID,
0147                      const xmlChar *SystemID);
0148 #ifdef LIBXML_TREE_ENABLED
0149 XMLPUBFUN xmlNotationTablePtr
0150         xmlCopyNotationTable    (xmlNotationTablePtr table);
0151 #endif /* LIBXML_TREE_ENABLED */
0152 XMLPUBFUN void
0153         xmlFreeNotationTable    (xmlNotationTablePtr table);
0154 #ifdef LIBXML_OUTPUT_ENABLED
0155 XML_DEPRECATED
0156 XMLPUBFUN void
0157         xmlDumpNotationDecl (xmlBufferPtr buf,
0158                      xmlNotationPtr nota);
0159 /* XML_DEPRECATED, still used in lxml */
0160 XMLPUBFUN void
0161         xmlDumpNotationTable    (xmlBufferPtr buf,
0162                      xmlNotationTablePtr table);
0163 #endif /* LIBXML_OUTPUT_ENABLED */
0164 
0165 /* Element Content */
0166 /* the non Doc version are being deprecated */
0167 XMLPUBFUN xmlElementContentPtr
0168         xmlNewElementContent    (const xmlChar *name,
0169                      xmlElementContentType type);
0170 XMLPUBFUN xmlElementContentPtr
0171         xmlCopyElementContent   (xmlElementContentPtr content);
0172 XMLPUBFUN void
0173         xmlFreeElementContent   (xmlElementContentPtr cur);
0174 /* the new versions with doc argument */
0175 XMLPUBFUN xmlElementContentPtr
0176         xmlNewDocElementContent (xmlDocPtr doc,
0177                      const xmlChar *name,
0178                      xmlElementContentType type);
0179 XMLPUBFUN xmlElementContentPtr
0180         xmlCopyDocElementContent(xmlDocPtr doc,
0181                      xmlElementContentPtr content);
0182 XMLPUBFUN void
0183         xmlFreeDocElementContent(xmlDocPtr doc,
0184                      xmlElementContentPtr cur);
0185 XMLPUBFUN void
0186         xmlSnprintfElementContent(char *buf,
0187                      int size,
0188                                      xmlElementContentPtr content,
0189                      int englob);
0190 #ifdef LIBXML_OUTPUT_ENABLED
0191 XML_DEPRECATED
0192 XMLPUBFUN void
0193         xmlSprintfElementContent(char *buf,
0194                                      xmlElementContentPtr content,
0195                      int englob);
0196 #endif /* LIBXML_OUTPUT_ENABLED */
0197 
0198 /* Element */
0199 XMLPUBFUN xmlElementPtr
0200         xmlAddElementDecl   (xmlValidCtxtPtr ctxt,
0201                      xmlDtdPtr dtd,
0202                      const xmlChar *name,
0203                      xmlElementTypeVal type,
0204                      xmlElementContentPtr content);
0205 #ifdef LIBXML_TREE_ENABLED
0206 XMLPUBFUN xmlElementTablePtr
0207         xmlCopyElementTable (xmlElementTablePtr table);
0208 #endif /* LIBXML_TREE_ENABLED */
0209 XMLPUBFUN void
0210         xmlFreeElementTable (xmlElementTablePtr table);
0211 #ifdef LIBXML_OUTPUT_ENABLED
0212 XML_DEPRECATED
0213 XMLPUBFUN void
0214         xmlDumpElementTable (xmlBufferPtr buf,
0215                      xmlElementTablePtr table);
0216 XML_DEPRECATED
0217 XMLPUBFUN void
0218         xmlDumpElementDecl  (xmlBufferPtr buf,
0219                      xmlElementPtr elem);
0220 #endif /* LIBXML_OUTPUT_ENABLED */
0221 
0222 /* Enumeration */
0223 XMLPUBFUN xmlEnumerationPtr
0224         xmlCreateEnumeration    (const xmlChar *name);
0225 XMLPUBFUN void
0226         xmlFreeEnumeration  (xmlEnumerationPtr cur);
0227 #ifdef LIBXML_TREE_ENABLED
0228 XMLPUBFUN xmlEnumerationPtr
0229         xmlCopyEnumeration  (xmlEnumerationPtr cur);
0230 #endif /* LIBXML_TREE_ENABLED */
0231 
0232 /* Attribute */
0233 XMLPUBFUN xmlAttributePtr
0234         xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
0235                      xmlDtdPtr dtd,
0236                      const xmlChar *elem,
0237                      const xmlChar *name,
0238                      const xmlChar *ns,
0239                      xmlAttributeType type,
0240                      xmlAttributeDefault def,
0241                      const xmlChar *defaultValue,
0242                      xmlEnumerationPtr tree);
0243 #ifdef LIBXML_TREE_ENABLED
0244 XMLPUBFUN xmlAttributeTablePtr
0245         xmlCopyAttributeTable  (xmlAttributeTablePtr table);
0246 #endif /* LIBXML_TREE_ENABLED */
0247 XMLPUBFUN void
0248         xmlFreeAttributeTable  (xmlAttributeTablePtr table);
0249 #ifdef LIBXML_OUTPUT_ENABLED
0250 XML_DEPRECATED
0251 XMLPUBFUN void
0252         xmlDumpAttributeTable  (xmlBufferPtr buf,
0253                     xmlAttributeTablePtr table);
0254 XML_DEPRECATED
0255 XMLPUBFUN void
0256         xmlDumpAttributeDecl   (xmlBufferPtr buf,
0257                     xmlAttributePtr attr);
0258 #endif /* LIBXML_OUTPUT_ENABLED */
0259 
0260 /* IDs */
0261 XMLPUBFUN int
0262         xmlAddIDSafe           (xmlAttrPtr attr,
0263                     const xmlChar *value);
0264 XMLPUBFUN xmlIDPtr
0265         xmlAddID           (xmlValidCtxtPtr ctxt,
0266                     xmlDocPtr doc,
0267                     const xmlChar *value,
0268                     xmlAttrPtr attr);
0269 XMLPUBFUN void
0270         xmlFreeIDTable         (xmlIDTablePtr table);
0271 XMLPUBFUN xmlAttrPtr
0272         xmlGetID           (xmlDocPtr doc,
0273                     const xmlChar *ID);
0274 XMLPUBFUN int
0275         xmlIsID            (xmlDocPtr doc,
0276                     xmlNodePtr elem,
0277                     xmlAttrPtr attr);
0278 XMLPUBFUN int
0279         xmlRemoveID        (xmlDocPtr doc,
0280                     xmlAttrPtr attr);
0281 
0282 /* IDREFs */
0283 XML_DEPRECATED
0284 XMLPUBFUN xmlRefPtr
0285         xmlAddRef          (xmlValidCtxtPtr ctxt,
0286                     xmlDocPtr doc,
0287                     const xmlChar *value,
0288                     xmlAttrPtr attr);
0289 XML_DEPRECATED
0290 XMLPUBFUN void
0291         xmlFreeRefTable        (xmlRefTablePtr table);
0292 XML_DEPRECATED
0293 XMLPUBFUN int
0294         xmlIsRef           (xmlDocPtr doc,
0295                     xmlNodePtr elem,
0296                     xmlAttrPtr attr);
0297 XML_DEPRECATED
0298 XMLPUBFUN int
0299         xmlRemoveRef           (xmlDocPtr doc,
0300                     xmlAttrPtr attr);
0301 XML_DEPRECATED
0302 XMLPUBFUN xmlListPtr
0303         xmlGetRefs         (xmlDocPtr doc,
0304                     const xmlChar *ID);
0305 
0306 /**
0307  * The public function calls related to validity checking.
0308  */
0309 #ifdef LIBXML_VALID_ENABLED
0310 /* Allocate/Release Validation Contexts */
0311 XMLPUBFUN xmlValidCtxtPtr
0312         xmlNewValidCtxt(void);
0313 XMLPUBFUN void
0314         xmlFreeValidCtxt(xmlValidCtxtPtr);
0315 
0316 XML_DEPRECATED
0317 XMLPUBFUN int
0318         xmlValidateRoot     (xmlValidCtxtPtr ctxt,
0319                      xmlDocPtr doc);
0320 XML_DEPRECATED
0321 XMLPUBFUN int
0322         xmlValidateElementDecl  (xmlValidCtxtPtr ctxt,
0323                      xmlDocPtr doc,
0324                                  xmlElementPtr elem);
0325 XML_DEPRECATED
0326 XMLPUBFUN xmlChar *
0327         xmlValidNormalizeAttributeValue(xmlDocPtr doc,
0328                      xmlNodePtr elem,
0329                      const xmlChar *name,
0330                      const xmlChar *value);
0331 XML_DEPRECATED
0332 XMLPUBFUN xmlChar *
0333         xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
0334                      xmlDocPtr doc,
0335                      xmlNodePtr elem,
0336                      const xmlChar *name,
0337                      const xmlChar *value);
0338 XML_DEPRECATED
0339 XMLPUBFUN int
0340         xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
0341                      xmlDocPtr doc,
0342                                  xmlAttributePtr attr);
0343 XML_DEPRECATED
0344 XMLPUBFUN int
0345         xmlValidateAttributeValue(xmlAttributeType type,
0346                      const xmlChar *value);
0347 XML_DEPRECATED
0348 XMLPUBFUN int
0349         xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
0350                      xmlDocPtr doc,
0351                                  xmlNotationPtr nota);
0352 XMLPUBFUN int
0353         xmlValidateDtd      (xmlValidCtxtPtr ctxt,
0354                      xmlDocPtr doc,
0355                      xmlDtdPtr dtd);
0356 XML_DEPRECATED
0357 XMLPUBFUN int
0358         xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
0359                      xmlDocPtr doc);
0360 XMLPUBFUN int
0361         xmlValidateDocument (xmlValidCtxtPtr ctxt,
0362                      xmlDocPtr doc);
0363 XMLPUBFUN int
0364         xmlValidateElement  (xmlValidCtxtPtr ctxt,
0365                      xmlDocPtr doc,
0366                      xmlNodePtr elem);
0367 XML_DEPRECATED
0368 XMLPUBFUN int
0369         xmlValidateOneElement   (xmlValidCtxtPtr ctxt,
0370                      xmlDocPtr doc,
0371                                  xmlNodePtr elem);
0372 XML_DEPRECATED
0373 XMLPUBFUN int
0374         xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
0375                      xmlDocPtr doc,
0376                      xmlNodePtr elem,
0377                      xmlAttrPtr attr,
0378                      const xmlChar *value);
0379 XML_DEPRECATED
0380 XMLPUBFUN int
0381         xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
0382                      xmlDocPtr doc,
0383                      xmlNodePtr elem,
0384                      const xmlChar *prefix,
0385                      xmlNsPtr ns,
0386                      const xmlChar *value);
0387 XML_DEPRECATED
0388 XMLPUBFUN int
0389         xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
0390                      xmlDocPtr doc);
0391 #endif /* LIBXML_VALID_ENABLED */
0392 
0393 #if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
0394 XML_DEPRECATED
0395 XMLPUBFUN int
0396         xmlValidateNotationUse  (xmlValidCtxtPtr ctxt,
0397                      xmlDocPtr doc,
0398                      const xmlChar *notationName);
0399 #endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
0400 
0401 XMLPUBFUN int
0402         xmlIsMixedElement   (xmlDocPtr doc,
0403                      const xmlChar *name);
0404 XMLPUBFUN xmlAttributePtr
0405         xmlGetDtdAttrDesc   (xmlDtdPtr dtd,
0406                      const xmlChar *elem,
0407                      const xmlChar *name);
0408 XMLPUBFUN xmlAttributePtr
0409         xmlGetDtdQAttrDesc  (xmlDtdPtr dtd,
0410                      const xmlChar *elem,
0411                      const xmlChar *name,
0412                      const xmlChar *prefix);
0413 XMLPUBFUN xmlNotationPtr
0414         xmlGetDtdNotationDesc   (xmlDtdPtr dtd,
0415                      const xmlChar *name);
0416 XMLPUBFUN xmlElementPtr
0417         xmlGetDtdQElementDesc   (xmlDtdPtr dtd,
0418                      const xmlChar *name,
0419                      const xmlChar *prefix);
0420 XMLPUBFUN xmlElementPtr
0421         xmlGetDtdElementDesc    (xmlDtdPtr dtd,
0422                      const xmlChar *name);
0423 
0424 #ifdef LIBXML_VALID_ENABLED
0425 
0426 XMLPUBFUN int
0427         xmlValidGetPotentialChildren(xmlElementContent *ctree,
0428                      const xmlChar **names,
0429                      int *len,
0430                      int max);
0431 
0432 XMLPUBFUN int
0433         xmlValidGetValidElements(xmlNode *prev,
0434                      xmlNode *next,
0435                      const xmlChar **names,
0436                      int max);
0437 XMLPUBFUN int
0438         xmlValidateNameValue    (const xmlChar *value);
0439 XMLPUBFUN int
0440         xmlValidateNamesValue   (const xmlChar *value);
0441 XMLPUBFUN int
0442         xmlValidateNmtokenValue (const xmlChar *value);
0443 XMLPUBFUN int
0444         xmlValidateNmtokensValue(const xmlChar *value);
0445 
0446 #ifdef LIBXML_REGEXP_ENABLED
0447 /*
0448  * Validation based on the regexp support
0449  */
0450 XML_DEPRECATED
0451 XMLPUBFUN int
0452         xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
0453                      xmlElementPtr elem);
0454 
0455 XML_DEPRECATED
0456 XMLPUBFUN int
0457         xmlValidatePushElement  (xmlValidCtxtPtr ctxt,
0458                      xmlDocPtr doc,
0459                      xmlNodePtr elem,
0460                      const xmlChar *qname);
0461 XML_DEPRECATED
0462 XMLPUBFUN int
0463         xmlValidatePushCData    (xmlValidCtxtPtr ctxt,
0464                      const xmlChar *data,
0465                      int len);
0466 XML_DEPRECATED
0467 XMLPUBFUN int
0468         xmlValidatePopElement   (xmlValidCtxtPtr ctxt,
0469                      xmlDocPtr doc,
0470                      xmlNodePtr elem,
0471                      const xmlChar *qname);
0472 #endif /* LIBXML_REGEXP_ENABLED */
0473 #endif /* LIBXML_VALID_ENABLED */
0474 #ifdef __cplusplus
0475 }
0476 #endif
0477 #endif /* __XML_VALID_H__ */