Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 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__ |
Daniel Veillard | c26087b | 1999-08-30 11:23:51 +0000 | [diff] [blame] | 12 | |
Daniel Veillard | 10cb900 | 1999-11-12 17:02:31 +0000 | [diff] [blame] | 13 | #include "tree.h" |
| 14 | |
Daniel Veillard | c26087b | 1999-08-30 11:23:51 +0000 | [diff] [blame] | 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 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 | |
| 26 | typedef struct xmlValidCtxt { |
| 27 | void *userData; /* user specific data block */ |
| 28 | xmlValidityErrorFunc error; /* the callback in case of errors */ |
| 29 | xmlValidityWarningFunc warning; /* the callback in case of warning */ |
| 30 | } xmlValidCtxt, *xmlValidCtxtPtr; |
| 31 | |
Daniel Veillard | 3b9def1 | 1999-01-31 22:15:06 +0000 | [diff] [blame] | 32 | /* |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 33 | * ALl notation declarations are stored in a table |
| 34 | * there is one table per DTD |
| 35 | */ |
| 36 | |
| 37 | #define XML_MIN_NOTATION_TABLE 32 |
| 38 | |
| 39 | typedef struct xmlNotationTable { |
| 40 | int nb_notations; /* number of notations stored */ |
| 41 | int max_notations; /* maximum number of notations */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 42 | xmlNotationPtr *table; /* the table of attributes */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 43 | } xmlNotationTable; |
| 44 | typedef xmlNotationTable *xmlNotationTablePtr; |
| 45 | |
| 46 | /* |
Daniel Veillard | 3b9def1 | 1999-01-31 22:15:06 +0000 | [diff] [blame] | 47 | * ALl element declarations are stored in a table |
| 48 | * there is one table per DTD |
| 49 | */ |
| 50 | |
| 51 | #define XML_MIN_ELEMENT_TABLE 32 |
| 52 | |
| 53 | typedef struct xmlElementTable { |
| 54 | int nb_elements; /* number of elements stored */ |
| 55 | int max_elements; /* maximum number of elements */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 56 | xmlElementPtr *table; /* the table of elements */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 57 | } xmlElementTable; |
| 58 | typedef xmlElementTable *xmlElementTablePtr; |
Daniel Veillard | 3b9def1 | 1999-01-31 22:15:06 +0000 | [diff] [blame] | 59 | |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 60 | /* |
| 61 | * ALl attribute declarations are stored in a table |
| 62 | * there is one table per DTD |
| 63 | */ |
| 64 | |
| 65 | #define XML_MIN_ATTRIBUTE_TABLE 32 |
| 66 | |
| 67 | typedef struct xmlAttributeTable { |
| 68 | int nb_attributes; /* number of attributes stored */ |
| 69 | int max_attributes; /* maximum number of attributes */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 70 | xmlAttributePtr *table; /* the table of attributes */ |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 71 | } xmlAttributeTable; |
| 72 | typedef xmlAttributeTable *xmlAttributeTablePtr; |
| 73 | |
Daniel Veillard | 991e63d | 1999-08-15 23:32:28 +0000 | [diff] [blame] | 74 | /* |
| 75 | * ALl IDs attributes are stored in a table |
| 76 | * there is one table per document |
| 77 | */ |
| 78 | |
| 79 | #define XML_MIN_ID_TABLE 32 |
| 80 | |
| 81 | typedef struct xmlIDTable { |
| 82 | int nb_ids; /* number of ids stored */ |
| 83 | int max_ids; /* maximum number of ids */ |
| 84 | xmlIDPtr *table; /* the table of ids */ |
| 85 | } xmlIDTable; |
| 86 | typedef xmlIDTable *xmlIDTablePtr; |
| 87 | |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 88 | /* |
| 89 | * ALl Refs attributes are stored in a table |
| 90 | * there is one table per document |
| 91 | */ |
| 92 | |
| 93 | #define XML_MIN_REF_TABLE 32 |
| 94 | |
| 95 | typedef struct xmlRefTable { |
| 96 | int nb_refs; /* number of refs stored */ |
| 97 | int max_refs; /* maximum number of refs */ |
| 98 | xmlRefPtr *table; /* the table of refs */ |
| 99 | } xmlRefTable; |
| 100 | typedef xmlRefTable *xmlRefTablePtr; |
| 101 | |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 102 | /* Notation */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 103 | xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt, |
| 104 | xmlDtdPtr dtd, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 105 | const xmlChar *name, |
| 106 | const xmlChar *PublicID, |
| 107 | const xmlChar *SystemID); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 108 | xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 109 | void xmlFreeNotationTable(xmlNotationTablePtr table); |
| 110 | void xmlDumpNotationTable(xmlBufferPtr buf, |
| 111 | xmlNotationTablePtr table); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 112 | |
| 113 | /* Element Content */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 114 | xmlElementContentPtr xmlNewElementContent (xmlChar *name, |
Daniel Veillard | c26087b | 1999-08-30 11:23:51 +0000 | [diff] [blame] | 115 | xmlElementContentType type); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 116 | xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 117 | void xmlFreeElementContent(xmlElementContentPtr cur); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 118 | |
| 119 | /* Element */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 120 | xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt, |
| 121 | xmlDtdPtr dtd, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 122 | const xmlChar *name, |
Daniel Veillard | 51e3b15 | 1999-11-12 17:02:31 +0000 | [diff] [blame] | 123 | xmlElementTypeVal type, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 124 | xmlElementContentPtr content); |
| 125 | xmlElementTablePtr xmlCopyElementTable (xmlElementTablePtr table); |
| 126 | void xmlFreeElementTable (xmlElementTablePtr table); |
| 127 | void xmlDumpElementTable (xmlBufferPtr buf, |
| 128 | xmlElementTablePtr table); |
Daniel Veillard | 3b9def1 | 1999-01-31 22:15:06 +0000 | [diff] [blame] | 129 | |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 130 | /* Enumeration */ |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 131 | xmlEnumerationPtr xmlCreateEnumeration (xmlChar *name); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 132 | void xmlFreeEnumeration (xmlEnumerationPtr cur); |
| 133 | xmlEnumerationPtr xmlCopyEnumeration (xmlEnumerationPtr cur); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 134 | |
| 135 | /* Attribute */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 136 | xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, |
| 137 | xmlDtdPtr dtd, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 138 | const xmlChar *elem, |
| 139 | const xmlChar *name, |
Daniel Veillard | c26087b | 1999-08-30 11:23:51 +0000 | [diff] [blame] | 140 | xmlAttributeType type, |
| 141 | xmlAttributeDefault def, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 142 | const xmlChar *defaultValue, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 143 | xmlEnumerationPtr tree); |
| 144 | xmlAttributeTablePtr xmlCopyAttributeTable (xmlAttributeTablePtr table); |
| 145 | void xmlFreeAttributeTable (xmlAttributeTablePtr table); |
| 146 | void xmlDumpAttributeTable (xmlBufferPtr buf, |
| 147 | xmlAttributeTablePtr table); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 148 | |
Daniel Veillard | 991e63d | 1999-08-15 23:32:28 +0000 | [diff] [blame] | 149 | /* IDs */ |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 150 | xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt, |
| 151 | xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 152 | const xmlChar *value, |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 153 | xmlAttrPtr attr); |
| 154 | xmlIDTablePtr xmlCopyIDTable (xmlIDTablePtr table); |
| 155 | void xmlFreeIDTable (xmlIDTablePtr table); |
| 156 | xmlAttrPtr xmlGetID (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 157 | const xmlChar *ID); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 158 | int xmlIsID (xmlDocPtr doc, |
| 159 | xmlNodePtr elem, |
| 160 | xmlAttrPtr attr); |
Daniel Veillard | 991e63d | 1999-08-15 23:32:28 +0000 | [diff] [blame] | 161 | |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 162 | /* IDREFs */ |
| 163 | xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt, |
| 164 | xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 165 | const xmlChar *value, |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 166 | xmlAttrPtr attr); |
| 167 | xmlRefTablePtr xmlCopyRefTable (xmlRefTablePtr table); |
| 168 | void xmlFreeRefTable (xmlRefTablePtr table); |
| 169 | int xmlIsRef (xmlDocPtr doc, |
| 170 | xmlNodePtr elem, |
| 171 | xmlAttrPtr attr); |
| 172 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame] | 173 | /** |
| 174 | * The public function calls related to validity checking |
| 175 | */ |
| 176 | |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 177 | int xmlValidateRoot (xmlValidCtxtPtr ctxt, |
| 178 | xmlDocPtr doc); |
| 179 | int xmlValidateElementDecl (xmlValidCtxtPtr ctxt, |
| 180 | xmlDocPtr doc, |
| 181 | xmlElementPtr elem); |
| 182 | int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, |
| 183 | xmlDocPtr doc, |
| 184 | xmlAttributePtr attr); |
| 185 | int xmlValidateAttributeValue(xmlAttributeType type, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 186 | const xmlChar *value); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 187 | int xmlValidateNotationDecl (xmlValidCtxtPtr ctxt, |
| 188 | xmlDocPtr doc, |
| 189 | xmlNotationPtr nota); |
| 190 | int xmlValidateDtd (xmlValidCtxtPtr ctxt, |
| 191 | xmlDocPtr doc, |
| 192 | xmlDtdPtr dtd); |
| 193 | int xmlValidateDocument (xmlValidCtxtPtr ctxt, |
| 194 | xmlDocPtr doc); |
| 195 | int xmlValidateElement (xmlValidCtxtPtr ctxt, |
| 196 | xmlDocPtr doc, |
| 197 | xmlNodePtr elem); |
| 198 | int xmlValidateOneElement (xmlValidCtxtPtr ctxt, |
| 199 | xmlDocPtr doc, |
| 200 | xmlNodePtr elem); |
| 201 | int xmlValidateOneAttribute (xmlValidCtxtPtr ctxt, |
| 202 | xmlDocPtr doc, |
| 203 | xmlNodePtr elem, |
| 204 | xmlAttrPtr attr, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 205 | const xmlChar *value); |
Daniel Veillard | c08a2c6 | 1999-09-08 21:35:25 +0000 | [diff] [blame] | 206 | int xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, |
| 207 | xmlDocPtr doc); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 208 | int xmlValidateNotationUse (xmlValidCtxtPtr ctxt, |
| 209 | xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 210 | const xmlChar *notationName); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 211 | int xmlIsMixedElement (xmlDocPtr doc, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 212 | const xmlChar *name); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 213 | xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 214 | const xmlChar *elem, |
| 215 | const xmlChar *name); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 216 | xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 217 | const xmlChar *name); |
Daniel Veillard | b96e643 | 1999-08-29 21:02:19 +0000 | [diff] [blame] | 218 | xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd, |
Daniel Veillard | dd6b367 | 1999-09-23 22:19:22 +0000 | [diff] [blame] | 219 | const xmlChar *name); |
Daniel Veillard | c26087b | 1999-08-30 11:23:51 +0000 | [diff] [blame] | 220 | |
Daniel Veillard | 7c1206f | 1999-10-14 09:10:25 +0000 | [diff] [blame] | 221 | int xmlValidGetValidElements(xmlNode *prev, |
| 222 | xmlNode *next, |
| 223 | const xmlChar **list, |
| 224 | int max); |
| 225 | int xmlValidGetPotentialChildren(xmlElementContent *ctree, |
| 226 | const xmlChar **list, |
| 227 | int *len, |
| 228 | int max); |
Daniel Veillard | c26087b | 1999-08-30 11:23:51 +0000 | [diff] [blame] | 229 | #ifdef __cplusplus |
| 230 | } |
| 231 | #endif |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 232 | #endif /* __XML_VALID_H__ */ |