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 | |
| 72 | /* Notation */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame^] | 73 | xmlNotationPtr xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, |
| 74 | const CHAR *name, const CHAR *PublicID, const CHAR *SystemID); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 75 | xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table); |
| 76 | void xmlFreeNotationTable(xmlNotationTablePtr table); |
Daniel Veillard | 5099ae8 | 1999-04-21 20:12:07 +0000 | [diff] [blame] | 77 | void xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 78 | |
| 79 | /* Element Content */ |
| 80 | xmlElementContentPtr xmlNewElementContent(CHAR *name, int type); |
| 81 | xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content); |
| 82 | void xmlFreeElementContent(xmlElementContentPtr cur); |
| 83 | |
| 84 | /* Element */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame^] | 85 | xmlElementPtr xmlAddElementDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, |
| 86 | const CHAR *name, int type, xmlElementContentPtr content); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 87 | xmlElementTablePtr xmlCopyElementTable(xmlElementTablePtr table); |
| 88 | void xmlFreeElementTable(xmlElementTablePtr table); |
Daniel Veillard | 5099ae8 | 1999-04-21 20:12:07 +0000 | [diff] [blame] | 89 | void xmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table); |
Daniel Veillard | 3b9def1 | 1999-01-31 22:15:06 +0000 | [diff] [blame] | 90 | |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 91 | /* Enumeration */ |
| 92 | xmlEnumerationPtr xmlCreateEnumeration(CHAR *name); |
| 93 | void xmlFreeEnumeration(xmlEnumerationPtr cur); |
| 94 | xmlEnumerationPtr xmlCopyEnumeration(xmlEnumerationPtr cur); |
| 95 | |
| 96 | /* Attribute */ |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame^] | 97 | xmlAttributePtr xmlAddAttributeDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, |
| 98 | const CHAR *elem, const CHAR *name, int type, int def, |
Daniel Veillard | 517752b | 1999-04-05 12:20:10 +0000 | [diff] [blame] | 99 | const CHAR *defaultValue, xmlEnumerationPtr tree); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 100 | xmlAttributeTablePtr xmlCopyAttributeTable(xmlAttributeTablePtr table); |
| 101 | void xmlFreeAttributeTable(xmlAttributeTablePtr table); |
Daniel Veillard | 5099ae8 | 1999-04-21 20:12:07 +0000 | [diff] [blame] | 102 | void xmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table); |
Daniel Veillard | 1e346af | 1999-02-22 10:33:01 +0000 | [diff] [blame] | 103 | |
Daniel Veillard | b05deb7 | 1999-08-10 19:04:08 +0000 | [diff] [blame^] | 104 | /** |
| 105 | * The public function calls related to validity checking |
| 106 | */ |
| 107 | |
| 108 | int xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc); |
| 109 | int xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 110 | xmlElementPtr elem); |
| 111 | int xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 112 | xmlAttributePtr attr); |
| 113 | int xmlValidateNotationDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 114 | xmlNotationPtr nota); |
| 115 | int xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd); |
| 116 | |
| 117 | int xmlValidateDocument(xmlValidCtxtPtr ctxt, xmlDocPtr doc); |
| 118 | int xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem); |
| 119 | int xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 120 | xmlNodePtr elem); |
| 121 | int xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 122 | xmlNodePtr elem, xmlAttrPtr attr, const CHAR *value); |
| 123 | |
| 124 | int xmlIsMixedElement(xmlDocPtr doc, const CHAR *name); |
Daniel Veillard | 39a1f9a | 1999-01-17 19:11:59 +0000 | [diff] [blame] | 125 | #endif /* __XML_VALID_H__ */ |