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