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