Annotation of XML/valid.h, revision 1.30

1.1       daniel      1: /*
                      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__
1.16      daniel     12: 
1.30    ! daniel     13: #include <libxml/tree.h>
1.23      daniel     14: 
1.16      daniel     15: #ifdef __cplusplus
                     16: extern "C" {
                     17: #endif
1.1       daniel     18: 
1.9       daniel     19: /**
                     20:  * an xmlValidCtxt is used for error reporting when validating
                     21:  */
                     22: 
                     23: typedef void (*xmlValidityErrorFunc) (void *ctx, const char *msg, ...);
                     24: typedef void (*xmlValidityWarningFunc) (void *ctx, const char *msg, ...);
                     25: 
1.24      daniel     26: typedef struct _xmlValidCtxt xmlValidCtxt;
                     27: typedef xmlValidCtxt *xmlValidCtxtPtr;
                     28: struct _xmlValidCtxt {
1.9       daniel     29:     void *userData;                    /* user specific data block */
                     30:     xmlValidityErrorFunc error;                /* the callback in case of errors */
                     31:     xmlValidityWarningFunc warning;    /* the callback in case of warning */
1.27      daniel     32: 
                     33:     /* Node analysis stack used when validating within entities */
                     34:     xmlNodePtr         node;          /* Current parsed Node */
                     35:     int                nodeNr;        /* Depth of the parsing stack */
                     36:     int                nodeMax;       /* Max depth of the parsing stack */
                     37:     xmlNodePtr        *nodeTab;       /* array of nodes */
1.28      daniel     38: 
                     39:     int              finishDtd;       /* finished validating the Dtd ? */
1.24      daniel     40: };
1.9       daniel     41: 
1.2       daniel     42: /*
1.5       daniel     43:  * ALl notation declarations are stored in a table
                     44:  * there is one table per DTD
                     45:  */
                     46: 
                     47: #define XML_MIN_NOTATION_TABLE 32
                     48: 
1.24      daniel     49: typedef struct _xmlNotationTable xmlNotationTable;
                     50: typedef xmlNotationTable *xmlNotationTablePtr;
                     51: struct _xmlNotationTable {
1.5       daniel     52:     int nb_notations;          /* number of notations stored */
                     53:     int max_notations;         /* maximum number of notations */
1.10      daniel     54:     xmlNotationPtr *table;     /* the table of attributes */
1.24      daniel     55: };
1.5       daniel     56: 
                     57: /*
1.2       daniel     58:  * ALl element declarations are stored in a table
                     59:  * there is one table per DTD
                     60:  */
                     61: 
                     62: #define XML_MIN_ELEMENT_TABLE  32
                     63: 
1.24      daniel     64: typedef struct _xmlElementTable xmlElementTable;
                     65: typedef xmlElementTable *xmlElementTablePtr;
                     66: struct _xmlElementTable {
1.2       daniel     67:     int nb_elements;           /* number of elements stored */
                     68:     int max_elements;          /* maximum number of elements */
1.10      daniel     69:     xmlElementPtr *table;      /* the table of elements */
1.24      daniel     70: };
1.2       daniel     71: 
1.5       daniel     72: /*
                     73:  * ALl attribute declarations are stored in a table
                     74:  * there is one table per DTD
                     75:  */
                     76: 
1.4       daniel     77: #define XML_MIN_ATTRIBUTE_TABLE        32
                     78: 
1.24      daniel     79: typedef struct _xmlAttributeTable xmlAttributeTable;
                     80: typedef xmlAttributeTable *xmlAttributeTablePtr;
                     81: struct _xmlAttributeTable {
1.4       daniel     82:     int nb_attributes;         /* number of attributes stored */
                     83:     int max_attributes;                /* maximum number of attributes */
1.10      daniel     84:     xmlAttributePtr *table;    /* the table of attributes */
1.24      daniel     85: };
1.4       daniel     86: 
1.13      daniel     87: /*
                     88:  * ALl IDs attributes are stored in a table
                     89:  * there is one table per document
                     90:  */
                     91: 
                     92: #define XML_MIN_ID_TABLE       32
                     93: 
1.24      daniel     94: typedef struct _xmlIDTable xmlIDTable;
                     95: typedef xmlIDTable *xmlIDTablePtr;
                     96: struct _xmlIDTable {
1.13      daniel     97:     int nb_ids;                        /* number of ids stored */
                     98:     int max_ids;               /* maximum number of ids */
                     99:     xmlIDPtr *table;           /* the table of ids */
1.24      daniel    100: };
1.13      daniel    101: 
1.17      daniel    102: /*
                    103:  * ALl Refs attributes are stored in a table
                    104:  * there is one table per document
                    105:  */
                    106: 
                    107: #define XML_MIN_REF_TABLE      32
                    108: 
1.24      daniel    109: typedef struct _xmlRefTable xmlRefTable;
                    110: typedef xmlRefTable *xmlRefTablePtr;
                    111: struct _xmlRefTable {
1.17      daniel    112:     int nb_refs;                       /* number of refs stored */
                    113:     int max_refs;              /* maximum number of refs */
                    114:     xmlRefPtr *table;          /* the table of refs */
1.24      daniel    115: };
1.17      daniel    116: 
1.5       daniel    117: /* Notation */
1.14      daniel    118: xmlNotationPtr     xmlAddNotationDecl  (xmlValidCtxtPtr ctxt,
                    119:                                         xmlDtdPtr dtd,
1.19      daniel    120:                                         const xmlChar *name,
                    121:                                         const xmlChar *PublicID,
                    122:                                         const xmlChar *SystemID);
1.6       daniel    123: xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
1.14      daniel    124: void               xmlFreeNotationTable(xmlNotationTablePtr table);
1.27      daniel    125: void               xmlDumpNotationDecl (xmlBufferPtr buf,
                    126:                                         xmlNotationPtr nota);
1.14      daniel    127: void               xmlDumpNotationTable(xmlBufferPtr buf,
                    128:                                         xmlNotationTablePtr table);
1.5       daniel    129: 
                    130: /* Element Content */
1.19      daniel    131: xmlElementContentPtr xmlNewElementContent (xmlChar *name,
1.16      daniel    132:                                           xmlElementContentType type);
1.6       daniel    133: xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
1.14      daniel    134: void                xmlFreeElementContent(xmlElementContentPtr cur);
1.25      daniel    135: void                xmlSprintfElementContent(char *buf,
                    136:                                           xmlElementContentPtr content,
                    137:                                           int glob);
1.2       daniel    138: 
1.5       daniel    139: /* Element */
1.14      daniel    140: xmlElementPtr     xmlAddElementDecl    (xmlValidCtxtPtr ctxt,
                    141:                                         xmlDtdPtr dtd,
1.19      daniel    142:                                         const xmlChar *name,
1.22      daniel    143:                                         xmlElementTypeVal type,
1.14      daniel    144:                                         xmlElementContentPtr content);
                    145: xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table);
                    146: void              xmlFreeElementTable  (xmlElementTablePtr table);
                    147: void              xmlDumpElementTable  (xmlBufferPtr buf,
                    148:                                         xmlElementTablePtr table);
1.27      daniel    149: void              xmlDumpElementDecl   (xmlBufferPtr buf,
                    150:                                         xmlElementPtr elem);
1.5       daniel    151: 
                    152: /* Enumeration */
1.19      daniel    153: xmlEnumerationPtr  xmlCreateEnumeration        (xmlChar *name);
1.14      daniel    154: void              xmlFreeEnumeration   (xmlEnumerationPtr cur);
                    155: xmlEnumerationPtr  xmlCopyEnumeration  (xmlEnumerationPtr cur);
1.5       daniel    156: 
                    157: /* Attribute */
1.14      daniel    158: xmlAttributePtr            xmlAddAttributeDecl     (xmlValidCtxtPtr ctxt,
                    159:                                             xmlDtdPtr dtd,
1.19      daniel    160:                                             const xmlChar *elem,
                    161:                                             const xmlChar *name,
1.26      daniel    162:                                             const xmlChar *prefix,
1.16      daniel    163:                                             xmlAttributeType type,
                    164:                                             xmlAttributeDefault def,
1.19      daniel    165:                                             const xmlChar *defaultValue,
1.14      daniel    166:                                             xmlEnumerationPtr tree);
                    167: xmlAttributeTablePtr xmlCopyAttributeTable  (xmlAttributeTablePtr table);
                    168: void                xmlFreeAttributeTable  (xmlAttributeTablePtr table);
                    169: void                xmlDumpAttributeTable  (xmlBufferPtr buf,
                    170:                                             xmlAttributeTablePtr table);
1.27      daniel    171: void                xmlDumpAttributeDecl   (xmlBufferPtr buf,
                    172:                                             xmlAttributePtr attr);
1.13      daniel    173: 
                    174: /* IDs */
1.14      daniel    175: xmlIDPtr       xmlAddID        (xmlValidCtxtPtr ctxt,
                    176:                                 xmlDocPtr doc,
1.19      daniel    177:                                 const xmlChar *value,
1.14      daniel    178:                                 xmlAttrPtr attr);
                    179: xmlIDTablePtr  xmlCopyIDTable  (xmlIDTablePtr table);
                    180: void           xmlFreeIDTable  (xmlIDTablePtr table);
                    181: xmlAttrPtr     xmlGetID        (xmlDocPtr doc,
1.19      daniel    182:                                 const xmlChar *ID);
1.14      daniel    183: int            xmlIsID         (xmlDocPtr doc,
1.17      daniel    184:                                 xmlNodePtr elem,
                    185:                                 xmlAttrPtr attr);
1.24      daniel    186: int            xmlRemoveID     (xmlDocPtr doc, xmlAttrPtr attr);
1.17      daniel    187: 
                    188: /* IDREFs */
                    189: xmlRefPtr      xmlAddRef       (xmlValidCtxtPtr ctxt,
                    190:                                 xmlDocPtr doc,
1.19      daniel    191:                                 const xmlChar *value,
1.17      daniel    192:                                 xmlAttrPtr attr);
                    193: xmlRefTablePtr xmlCopyRefTable (xmlRefTablePtr table);
                    194: void           xmlFreeRefTable (xmlRefTablePtr table);
                    195: int            xmlIsRef        (xmlDocPtr doc,
1.14      daniel    196:                                 xmlNodePtr elem,
                    197:                                 xmlAttrPtr attr);
1.24      daniel    198: int            xmlRemoveRef    (xmlDocPtr doc, xmlAttrPtr attr);
1.9       daniel    199: 
                    200: /**
                    201:  * The public function calls related to validity checking
                    202:  */
                    203: 
1.14      daniel    204: int            xmlValidateRoot         (xmlValidCtxtPtr ctxt,
                    205:                                         xmlDocPtr doc);
                    206: int            xmlValidateElementDecl  (xmlValidCtxtPtr ctxt,
                    207:                                         xmlDocPtr doc,
                    208:                                         xmlElementPtr elem);
1.29      daniel    209: xmlChar *      xmlValidNormalizeAttributeValue(xmlDocPtr doc,
                    210:                                         xmlNodePtr elem,
                    211:                                         const xmlChar *name,
                    212:                                         const xmlChar *value);
1.14      daniel    213: int            xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
                    214:                                         xmlDocPtr doc,
                    215:                                         xmlAttributePtr attr);
1.15      daniel    216: int            xmlValidateAttributeValue(xmlAttributeType type,
1.19      daniel    217:                                         const xmlChar *value);
1.14      daniel    218: int            xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
                    219:                                         xmlDocPtr doc,
                    220:                                         xmlNotationPtr nota);
                    221: int            xmlValidateDtd          (xmlValidCtxtPtr ctxt,
                    222:                                         xmlDocPtr doc,
                    223:                                         xmlDtdPtr dtd);
1.28      daniel    224: int            xmlValidateDtdFinal     (xmlValidCtxtPtr ctxt,
                    225:                                         xmlDocPtr doc);
1.14      daniel    226: int            xmlValidateDocument     (xmlValidCtxtPtr ctxt,
                    227:                                         xmlDocPtr doc);
                    228: int            xmlValidateElement      (xmlValidCtxtPtr ctxt,
                    229:                                         xmlDocPtr doc,
                    230:                                         xmlNodePtr elem);
                    231: int            xmlValidateOneElement   (xmlValidCtxtPtr ctxt,
                    232:                                         xmlDocPtr doc,
                    233:                                         xmlNodePtr elem);
                    234: int            xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
                    235:                                         xmlDocPtr doc,
                    236:                                         xmlNodePtr     elem,
                    237:                                         xmlAttrPtr attr,
1.19      daniel    238:                                         const xmlChar *value);
1.18      daniel    239: int            xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
                    240:                                         xmlDocPtr doc);
1.15      daniel    241: int            xmlValidateNotationUse  (xmlValidCtxtPtr ctxt,
                    242:                                         xmlDocPtr doc,
1.19      daniel    243:                                         const xmlChar *notationName);
1.14      daniel    244: int            xmlIsMixedElement       (xmlDocPtr doc,
1.19      daniel    245:                                         const xmlChar *name);
1.14      daniel    246: xmlAttributePtr        xmlGetDtdAttrDesc       (xmlDtdPtr dtd,
1.19      daniel    247:                                         const xmlChar *elem,
                    248:                                         const xmlChar *name);
1.14      daniel    249: xmlNotationPtr xmlGetDtdNotationDesc   (xmlDtdPtr dtd,
1.19      daniel    250:                                         const xmlChar *name);
1.14      daniel    251: xmlElementPtr  xmlGetDtdElementDesc    (xmlDtdPtr dtd,
1.19      daniel    252:                                         const xmlChar *name);
1.16      daniel    253: 
1.21      daniel    254: int            xmlValidGetValidElements(xmlNode *prev,
                    255:                                         xmlNode *next,
                    256:                                         const xmlChar **list,
                    257:                                         int max);
                    258: int            xmlValidGetPotentialChildren(xmlElementContent *ctree,
                    259:                                         const xmlChar **list,
                    260:                                         int *len,
                    261:                                         int max);
1.16      daniel    262: #ifdef __cplusplus
                    263: }
                    264: #endif
1.1       daniel    265: #endif /* __XML_VALID_H__ */

Webmaster