Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1 | /* |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 2 | * Summary: the core parser module |
| 3 | * Description: Interfaces, constants and types related to the XML parser |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 4 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 5 | * Copy: See Copyright for the status of this software. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 6 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 7 | * Author: Daniel Veillard |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __XML_PARSER_H__ |
| 11 | #define __XML_PARSER_H__ |
| 12 | |
Aleksey Sanin | b5a46da | 2003-10-29 15:51:17 +0000 | [diff] [blame] | 13 | #include <stdarg.h> |
| 14 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 15 | #include <libxml/xmlversion.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 16 | #include <libxml/tree.h> |
Daniel Veillard | 2fdbd32 | 2003-08-18 12:15:38 +0000 | [diff] [blame] | 17 | #include <libxml/dict.h> |
Daniel Veillard | 07cb822 | 2003-09-10 10:51:05 +0000 | [diff] [blame] | 18 | #include <libxml/hash.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 19 | #include <libxml/valid.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 20 | #include <libxml/entities.h> |
Daniel Veillard | 2b8c4a1 | 2003-10-02 22:28:19 +0000 | [diff] [blame] | 21 | #include <libxml/xmlerror.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 22 | |
| 23 | #ifdef __cplusplus |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
Daniel Veillard | 5e2dace | 2001-07-18 19:30:27 +0000 | [diff] [blame] | 27 | /** |
| 28 | * XML_DEFAULT_VERSION: |
| 29 | * |
| 30 | * The default version of XML used: 1.0 |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 31 | */ |
| 32 | #define XML_DEFAULT_VERSION "1.0" |
| 33 | |
| 34 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 35 | * xmlParserInput: |
| 36 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 37 | * An xmlParserInput is an input flow for the XML processor. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 38 | * Each entity parsed is associated an xmlParserInput (except the |
| 39 | * few predefined ones). This is the case both for internal entities |
| 40 | * - in which case the flow is already completely in memory - or |
| 41 | * external entities - in which case we use the buf structure for |
| 42 | * progressive reading and I18N conversions to the internal UTF-8 format. |
| 43 | */ |
| 44 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 45 | /** |
| 46 | * xmlParserInputDeallocate: |
| 47 | * @str: the string to deallocate |
| 48 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 49 | * Callback for freeing some parser input allocations. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 50 | */ |
| 51 | typedef void (* xmlParserInputDeallocate)(xmlChar *str); |
Daniel Veillard | 5e2dace | 2001-07-18 19:30:27 +0000 | [diff] [blame] | 52 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 53 | struct _xmlParserInput { |
| 54 | /* Input buffer */ |
| 55 | xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ |
| 56 | |
| 57 | const char *filename; /* The file analyzed, if any */ |
Daniel Veillard | 60087f3 | 2001-10-10 09:45:09 +0000 | [diff] [blame] | 58 | const char *directory; /* the directory/base of the file */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 59 | const xmlChar *base; /* Base of the array to parse */ |
| 60 | const xmlChar *cur; /* Current char being parsed */ |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 61 | const xmlChar *end; /* end of the array to parse */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 62 | int length; /* length if known */ |
| 63 | int line; /* Current line */ |
| 64 | int col; /* Current column */ |
Daniel Veillard | 3e59fc5 | 2003-04-18 12:34:58 +0000 | [diff] [blame] | 65 | /* |
| 66 | * NOTE: consumed is only tested for equality in the parser code, |
| 67 | * so even if there is an overflow this should not give troubles |
| 68 | * for parsing very large instances. |
| 69 | */ |
| 70 | unsigned long consumed; /* How many xmlChars already consumed */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 71 | xmlParserInputDeallocate free; /* function to deallocate the base */ |
| 72 | const xmlChar *encoding; /* the encoding string for entity */ |
| 73 | const xmlChar *version; /* the version string for entity */ |
| 74 | int standalone; /* Was that entity marked standalone */ |
Daniel Veillard | bdbe0d4 | 2003-09-14 19:56:14 +0000 | [diff] [blame] | 75 | int id; /* an unique identifier for the entity */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 79 | * xmlParserNodeInfo: |
| 80 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 81 | * The parser can be asked to collect Node informations, i.e. at what |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 82 | * place in the file they were detected. |
| 83 | * NOTE: This is off by default and not very well tested. |
| 84 | */ |
| 85 | typedef struct _xmlParserNodeInfo xmlParserNodeInfo; |
| 86 | typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; |
| 87 | |
| 88 | struct _xmlParserNodeInfo { |
| 89 | const struct _xmlNode* node; |
| 90 | /* Position & line # that text that created the node begins & ends on */ |
| 91 | unsigned long begin_pos; |
| 92 | unsigned long begin_line; |
| 93 | unsigned long end_pos; |
| 94 | unsigned long end_line; |
| 95 | }; |
| 96 | |
| 97 | typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; |
| 98 | typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; |
| 99 | struct _xmlParserNodeInfoSeq { |
| 100 | unsigned long maximum; |
| 101 | unsigned long length; |
| 102 | xmlParserNodeInfo* buffer; |
| 103 | }; |
| 104 | |
| 105 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 106 | * xmlParserInputState: |
| 107 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 108 | * The parser is now working also as a state based parser. |
| 109 | * The recursive one use the state info for entities processing. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 110 | */ |
| 111 | typedef enum { |
| 112 | XML_PARSER_EOF = -1, /* nothing is to be parsed */ |
| 113 | XML_PARSER_START = 0, /* nothing has been parsed */ |
| 114 | XML_PARSER_MISC, /* Misc* before int subset */ |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 115 | XML_PARSER_PI, /* Within a processing instruction */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 116 | XML_PARSER_DTD, /* within some DTD content */ |
| 117 | XML_PARSER_PROLOG, /* Misc* after internal subset */ |
| 118 | XML_PARSER_COMMENT, /* within a comment */ |
| 119 | XML_PARSER_START_TAG, /* within a start tag */ |
| 120 | XML_PARSER_CONTENT, /* within the content */ |
| 121 | XML_PARSER_CDATA_SECTION, /* within a CDATA section */ |
| 122 | XML_PARSER_END_TAG, /* within a closing tag */ |
| 123 | XML_PARSER_ENTITY_DECL, /* within an entity declaration */ |
| 124 | XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ |
| 125 | XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ |
| 126 | XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ |
| 127 | XML_PARSER_EPILOG, /* the Misc* after the last end tag */ |
Daniel Veillard | 4a7ae50 | 2002-02-18 19:18:17 +0000 | [diff] [blame] | 128 | XML_PARSER_IGNORE, /* within an IGNORED section */ |
| 129 | XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 130 | } xmlParserInputState; |
| 131 | |
| 132 | /** |
Daniel Veillard | d16df9f | 2001-05-23 13:44:21 +0000 | [diff] [blame] | 133 | * XML_DETECT_IDS: |
| 134 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 135 | * Bit in the loadsubset context field to tell to do ID/REFs lookups. |
| 136 | * Use it to initialize xmlLoadExtDtdDefaultValue. |
Daniel Veillard | d16df9f | 2001-05-23 13:44:21 +0000 | [diff] [blame] | 137 | */ |
| 138 | #define XML_DETECT_IDS 2 |
| 139 | |
| 140 | /** |
| 141 | * XML_COMPLETE_ATTRS: |
| 142 | * |
| 143 | * Bit in the loadsubset context field to tell to do complete the |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 144 | * elements attributes lists with the ones defaulted from the DTDs. |
| 145 | * Use it to initialize xmlLoadExtDtdDefaultValue. |
Daniel Veillard | d16df9f | 2001-05-23 13:44:21 +0000 | [diff] [blame] | 146 | */ |
| 147 | #define XML_COMPLETE_ATTRS 4 |
| 148 | |
| 149 | /** |
Daniel Veillard | ef8dd7b | 2003-03-23 12:02:56 +0000 | [diff] [blame] | 150 | * XML_SKIP_IDS: |
| 151 | * |
| 152 | * Bit in the loadsubset context field to tell to not do ID/REFs registration. |
| 153 | * Used to initialize xmlLoadExtDtdDefaultValue in some special cases. |
| 154 | */ |
| 155 | #define XML_SKIP_IDS 8 |
| 156 | |
| 157 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 158 | * xmlParserCtxt: |
| 159 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 160 | * The parser context. |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 161 | * NOTE This doesn't completely define the parser state, the (current ?) |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 162 | * design of the parser uses recursive function calls since this allow |
| 163 | * and easy mapping from the production rules of the specification |
| 164 | * to the actual code. The drawback is that the actual function call |
| 165 | * also reflect the parser state. However most of the parsing routines |
| 166 | * takes as the only argument the parser context pointer, so migrating |
| 167 | * to a state based parser for progressive parsing shouldn't be too hard. |
| 168 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 169 | struct _xmlParserCtxt { |
| 170 | struct _xmlSAXHandler *sax; /* The SAX handler */ |
| 171 | void *userData; /* For SAX interface only, used by DOM build */ |
| 172 | xmlDocPtr myDoc; /* the document being built */ |
| 173 | int wellFormed; /* is the document well formed */ |
| 174 | int replaceEntities; /* shall we replace entities ? */ |
| 175 | const xmlChar *version; /* the XML version string */ |
| 176 | const xmlChar *encoding; /* the declared encoding, if any */ |
| 177 | int standalone; /* standalone document */ |
| 178 | int html; /* an HTML(1)/Docbook(2) document */ |
| 179 | |
| 180 | /* Input stream stack */ |
| 181 | xmlParserInputPtr input; /* Current input stream */ |
| 182 | int inputNr; /* Number of current input streams */ |
| 183 | int inputMax; /* Max number of input streams */ |
| 184 | xmlParserInputPtr *inputTab; /* stack of inputs */ |
| 185 | |
| 186 | /* Node analysis stack only used for DOM building */ |
| 187 | xmlNodePtr node; /* Current parsed Node */ |
| 188 | int nodeNr; /* Depth of the parsing stack */ |
| 189 | int nodeMax; /* Max depth of the parsing stack */ |
| 190 | xmlNodePtr *nodeTab; /* array of nodes */ |
| 191 | |
| 192 | int record_info; /* Whether node info should be kept */ |
| 193 | xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ |
| 194 | |
| 195 | int errNo; /* error code */ |
| 196 | |
| 197 | int hasExternalSubset; /* reference and external subset */ |
| 198 | int hasPErefs; /* the internal subset has PE refs */ |
| 199 | int external; /* are we parsing an external entity */ |
| 200 | |
| 201 | int valid; /* is the document valid */ |
| 202 | int validate; /* shall we try to validate ? */ |
| 203 | xmlValidCtxt vctxt; /* The validity context */ |
| 204 | |
| 205 | xmlParserInputState instate; /* current type of input */ |
| 206 | int token; /* next char look-ahead */ |
| 207 | |
| 208 | char *directory; /* the data directory */ |
| 209 | |
| 210 | /* Node name stack */ |
Daniel Veillard | 2fdbd32 | 2003-08-18 12:15:38 +0000 | [diff] [blame] | 211 | const xmlChar *name; /* Current parsed Node */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 212 | int nameNr; /* Depth of the parsing stack */ |
| 213 | int nameMax; /* Max depth of the parsing stack */ |
Daniel Veillard | 2fdbd32 | 2003-08-18 12:15:38 +0000 | [diff] [blame] | 214 | const xmlChar * *nameTab; /* array of nodes */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 215 | |
| 216 | long nbChars; /* number of xmlChar processed */ |
| 217 | long checkIndex; /* used by progressive parsing lookup */ |
| 218 | int keepBlanks; /* ugly but ... */ |
| 219 | int disableSAX; /* SAX callbacks are disabled */ |
| 220 | int inSubset; /* Parsing is in int 1/ext 2 subset */ |
Daniel Veillard | 2fdbd32 | 2003-08-18 12:15:38 +0000 | [diff] [blame] | 221 | const xmlChar * intSubName; /* name of subset */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 222 | xmlChar * extSubURI; /* URI of external subset */ |
| 223 | xmlChar * extSubSystem; /* SYSTEM ID of external subset */ |
| 224 | |
| 225 | /* xml:space values */ |
| 226 | int * space; /* Should the parser preserve spaces */ |
| 227 | int spaceNr; /* Depth of the parsing stack */ |
| 228 | int spaceMax; /* Max depth of the parsing stack */ |
| 229 | int * spaceTab; /* array of space infos */ |
| 230 | |
| 231 | int depth; /* to prevent entity substitution loops */ |
| 232 | xmlParserInputPtr entity; /* used to check entities boundaries */ |
| 233 | int charset; /* encoding of the in-memory content |
| 234 | actually an xmlCharEncoding */ |
| 235 | int nodelen; /* Those two fields are there to */ |
| 236 | int nodemem; /* Speed up large node parsing */ |
| 237 | int pedantic; /* signal pedantic warnings */ |
| 238 | void *_private; /* For user data, libxml won't touch it */ |
| 239 | |
| 240 | int loadsubset; /* should the external subset be loaded */ |
Daniel Veillard | d9bad13 | 2001-07-23 19:39:43 +0000 | [diff] [blame] | 241 | int linenumbers; /* set line number in element content */ |
Daniel Veillard | 5d90b6c | 2001-08-22 14:29:45 +0000 | [diff] [blame] | 242 | void *catalogs; /* document's own catalog */ |
Daniel Veillard | dad3f68 | 2002-11-17 16:47:27 +0000 | [diff] [blame] | 243 | int recovery; /* run in recovery mode */ |
Daniel Veillard | a880b12 | 2003-04-21 21:36:41 +0000 | [diff] [blame] | 244 | int progressive; /* is this a progressive parsing */ |
Daniel Veillard | 2fdbd32 | 2003-08-18 12:15:38 +0000 | [diff] [blame] | 245 | xmlDictPtr dict; /* dictionnary for the parser */ |
Daniel Veillard | 40412cd | 2003-09-03 13:28:32 +0000 | [diff] [blame] | 246 | const xmlChar * *atts; /* array for the attributes callbacks */ |
Daniel Veillard | 6155d8a | 2003-08-19 15:01:28 +0000 | [diff] [blame] | 247 | int maxatts; /* the size of the array */ |
Daniel Veillard | 40412cd | 2003-09-03 13:28:32 +0000 | [diff] [blame] | 248 | int docdict; /* use strings from dict to build tree */ |
Daniel Veillard | 0fb1893 | 2003-09-07 09:14:37 +0000 | [diff] [blame] | 249 | |
| 250 | /* |
| 251 | * pre-interned strings |
| 252 | */ |
| 253 | const xmlChar *str_xml; |
| 254 | const xmlChar *str_xmlns; |
Daniel Veillard | 07cb822 | 2003-09-10 10:51:05 +0000 | [diff] [blame] | 255 | const xmlChar *str_xml_ns; |
Daniel Veillard | 0fb1893 | 2003-09-07 09:14:37 +0000 | [diff] [blame] | 256 | |
| 257 | /* |
Daniel Veillard | 07cb822 | 2003-09-10 10:51:05 +0000 | [diff] [blame] | 258 | * Everything below is used only by the new SAX mode |
Daniel Veillard | 0fb1893 | 2003-09-07 09:14:37 +0000 | [diff] [blame] | 259 | */ |
| 260 | int sax2; /* operating in the new SAX mode */ |
| 261 | int nsNr; /* the number of inherited namespaces */ |
| 262 | int nsMax; /* the size of the arrays */ |
| 263 | const xmlChar * *nsTab; /* the array of prefix/namespace name */ |
Daniel Veillard | 07cb822 | 2003-09-10 10:51:05 +0000 | [diff] [blame] | 264 | int *attallocs; /* which attribute were allocated */ |
| 265 | void * *pushTab; /* array of data for push */ |
| 266 | xmlHashTablePtr attsDefault; /* defaulted attributes if any */ |
| 267 | xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */ |
Daniel Veillard | 3b7840c | 2003-09-11 23:42:01 +0000 | [diff] [blame] | 268 | int nsWellFormed; /* is the document XML Nanespace okay */ |
Daniel Veillard | 9475a35 | 2003-09-26 12:47:50 +0000 | [diff] [blame] | 269 | int options; /* Extra options */ |
Daniel Veillard | 8a44e59 | 2003-09-15 14:50:06 +0000 | [diff] [blame] | 270 | |
| 271 | /* |
| 272 | * Those fields are needed only for treaming parsing so far |
| 273 | */ |
Daniel Veillard | 9475a35 | 2003-09-26 12:47:50 +0000 | [diff] [blame] | 274 | int dictNames; /* Use dictionary names for the tree */ |
| 275 | int freeElemsNr; /* number of freed element nodes */ |
| 276 | xmlNodePtr freeElems; /* List of freed element nodes */ |
| 277 | int freeAttrsNr; /* number of freed attributes nodes */ |
| 278 | xmlAttrPtr freeAttrs; /* List of freed attributes nodes */ |
Daniel Veillard | 2b8c4a1 | 2003-10-02 22:28:19 +0000 | [diff] [blame] | 279 | |
| 280 | /* |
| 281 | * the complete error informations for the last error. |
| 282 | */ |
| 283 | xmlError lastError; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 287 | * xmlSAXLocator: |
| 288 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 289 | * A SAX Locator. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 290 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 291 | struct _xmlSAXLocator { |
| 292 | const xmlChar *(*getPublicId)(void *ctx); |
| 293 | const xmlChar *(*getSystemId)(void *ctx); |
| 294 | int (*getLineNumber)(void *ctx); |
| 295 | int (*getColumnNumber)(void *ctx); |
| 296 | }; |
| 297 | |
| 298 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 299 | * xmlSAXHandler: |
| 300 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 301 | * A SAX handler is bunch of callbacks called by the parser when processing |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 302 | * of the input generate data or structure informations. |
| 303 | */ |
| 304 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 305 | /** |
| 306 | * resolveEntitySAXFunc: |
| 307 | * @ctx: the user data (XML parser context) |
| 308 | * @publicId: The public ID of the entity |
| 309 | * @systemId: The system ID of the entity |
| 310 | * |
| 311 | * Callback: |
| 312 | * The entity loader, to control the loading of external entities, |
| 313 | * the application can either: |
| 314 | * - override this resolveEntity() callback in the SAX block |
| 315 | * - or better use the xmlSetExternalEntityLoader() function to |
| 316 | * set up it's own entity resolution routine |
| 317 | * |
| 318 | * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. |
| 319 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 320 | typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 321 | const xmlChar *publicId, |
| 322 | const xmlChar *systemId); |
| 323 | /** |
| 324 | * internalSubsetSAXFunc: |
| 325 | * @ctx: the user data (XML parser context) |
| 326 | * @name: the root element name |
| 327 | * @ExternalID: the external ID |
| 328 | * @SystemID: the SYSTEM ID (e.g. filename or URL) |
| 329 | * |
| 330 | * Callback on internal subset declaration. |
| 331 | */ |
| 332 | typedef void (*internalSubsetSAXFunc) (void *ctx, |
| 333 | const xmlChar *name, |
| 334 | const xmlChar *ExternalID, |
| 335 | const xmlChar *SystemID); |
| 336 | /** |
| 337 | * externalSubsetSAXFunc: |
| 338 | * @ctx: the user data (XML parser context) |
| 339 | * @name: the root element name |
| 340 | * @ExternalID: the external ID |
| 341 | * @SystemID: the SYSTEM ID (e.g. filename or URL) |
| 342 | * |
| 343 | * Callback on external subset declaration. |
| 344 | */ |
| 345 | typedef void (*externalSubsetSAXFunc) (void *ctx, |
| 346 | const xmlChar *name, |
| 347 | const xmlChar *ExternalID, |
| 348 | const xmlChar *SystemID); |
| 349 | /** |
| 350 | * getEntitySAXFunc: |
| 351 | * @ctx: the user data (XML parser context) |
| 352 | * @name: The entity name |
| 353 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 354 | * Get an entity by name. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 355 | * |
| 356 | * Returns the xmlEntityPtr if found. |
| 357 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 358 | typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 359 | const xmlChar *name); |
| 360 | /** |
| 361 | * getParameterEntitySAXFunc: |
| 362 | * @ctx: the user data (XML parser context) |
| 363 | * @name: The entity name |
| 364 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 365 | * Get a parameter entity by name. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 366 | * |
| 367 | * Returns the xmlEntityPtr if found. |
| 368 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 369 | typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 370 | const xmlChar *name); |
| 371 | /** |
| 372 | * entityDeclSAXFunc: |
| 373 | * @ctx: the user data (XML parser context) |
| 374 | * @name: the entity name |
| 375 | * @type: the entity type |
| 376 | * @publicId: The public ID of the entity |
| 377 | * @systemId: The system ID of the entity |
| 378 | * @content: the entity value (without processing). |
| 379 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 380 | * An entity definition has been parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 381 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 382 | typedef void (*entityDeclSAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 383 | const xmlChar *name, |
| 384 | int type, |
| 385 | const xmlChar *publicId, |
| 386 | const xmlChar *systemId, |
| 387 | xmlChar *content); |
| 388 | /** |
| 389 | * notationDeclSAXFunc: |
| 390 | * @ctx: the user data (XML parser context) |
| 391 | * @name: The name of the notation |
| 392 | * @publicId: The public ID of the entity |
| 393 | * @systemId: The system ID of the entity |
| 394 | * |
| 395 | * What to do when a notation declaration has been parsed. |
| 396 | */ |
| 397 | typedef void (*notationDeclSAXFunc)(void *ctx, |
| 398 | const xmlChar *name, |
| 399 | const xmlChar *publicId, |
| 400 | const xmlChar *systemId); |
| 401 | /** |
| 402 | * attributeDeclSAXFunc: |
| 403 | * @ctx: the user data (XML parser context) |
| 404 | * @elem: the name of the element |
| 405 | * @fullname: the attribute name |
| 406 | * @type: the attribute type |
| 407 | * @def: the type of default value |
| 408 | * @defaultValue: the attribute default value |
| 409 | * @tree: the tree of enumerated value set |
| 410 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 411 | * An attribute definition has been parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 412 | */ |
| 413 | typedef void (*attributeDeclSAXFunc)(void *ctx, |
| 414 | const xmlChar *elem, |
| 415 | const xmlChar *fullname, |
| 416 | int type, |
| 417 | int def, |
| 418 | const xmlChar *defaultValue, |
| 419 | xmlEnumerationPtr tree); |
| 420 | /** |
| 421 | * elementDeclSAXFunc: |
| 422 | * @ctx: the user data (XML parser context) |
| 423 | * @name: the element name |
| 424 | * @type: the element type |
| 425 | * @content: the element value tree |
| 426 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 427 | * An element definition has been parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 428 | */ |
| 429 | typedef void (*elementDeclSAXFunc)(void *ctx, |
| 430 | const xmlChar *name, |
| 431 | int type, |
| 432 | xmlElementContentPtr content); |
| 433 | /** |
| 434 | * unparsedEntityDeclSAXFunc: |
| 435 | * @ctx: the user data (XML parser context) |
| 436 | * @name: The name of the entity |
| 437 | * @publicId: The public ID of the entity |
| 438 | * @systemId: The system ID of the entity |
| 439 | * @notationName: the name of the notation |
| 440 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 441 | * What to do when an unparsed entity declaration is parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 442 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 443 | typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 444 | const xmlChar *name, |
| 445 | const xmlChar *publicId, |
| 446 | const xmlChar *systemId, |
| 447 | const xmlChar *notationName); |
| 448 | /** |
| 449 | * setDocumentLocatorSAXFunc: |
| 450 | * @ctx: the user data (XML parser context) |
| 451 | * @loc: A SAX Locator |
| 452 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 453 | * Receive the document locator at startup, actually xmlDefaultSAXLocator. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 454 | * Everything is available on the context, so this is useless in our case. |
| 455 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 456 | typedef void (*setDocumentLocatorSAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 457 | xmlSAXLocatorPtr loc); |
| 458 | /** |
| 459 | * startDocumentSAXFunc: |
| 460 | * @ctx: the user data (XML parser context) |
| 461 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 462 | * Called when the document start being processed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 463 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 464 | typedef void (*startDocumentSAXFunc) (void *ctx); |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 465 | /** |
| 466 | * endDocumentSAXFunc: |
| 467 | * @ctx: the user data (XML parser context) |
| 468 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 469 | * Called when the document end has been detected. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 470 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 471 | typedef void (*endDocumentSAXFunc) (void *ctx); |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 472 | /** |
| 473 | * startElementSAXFunc: |
| 474 | * @ctx: the user data (XML parser context) |
| 475 | * @name: The element name, including namespace prefix |
| 476 | * @atts: An array of name/value attributes pairs, NULL terminated |
| 477 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 478 | * Called when an opening tag has been processed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 479 | */ |
| 480 | typedef void (*startElementSAXFunc) (void *ctx, |
| 481 | const xmlChar *name, |
| 482 | const xmlChar **atts); |
| 483 | /** |
| 484 | * endElementSAXFunc: |
| 485 | * @ctx: the user data (XML parser context) |
| 486 | * @name: The element name |
| 487 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 488 | * Called when the end of an element has been detected. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 489 | */ |
| 490 | typedef void (*endElementSAXFunc) (void *ctx, |
| 491 | const xmlChar *name); |
| 492 | /** |
| 493 | * attributeSAXFunc: |
| 494 | * @ctx: the user data (XML parser context) |
| 495 | * @name: The attribute name, including namespace prefix |
| 496 | * @value: The attribute value |
| 497 | * |
| 498 | * Handle an attribute that has been read by the parser. |
| 499 | * The default handling is to convert the attribute into an |
| 500 | * DOM subtree and past it in a new xmlAttr element added to |
| 501 | * the element. |
| 502 | */ |
| 503 | typedef void (*attributeSAXFunc) (void *ctx, |
| 504 | const xmlChar *name, |
| 505 | const xmlChar *value); |
| 506 | /** |
| 507 | * referenceSAXFunc: |
| 508 | * @ctx: the user data (XML parser context) |
| 509 | * @name: The entity name |
| 510 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 511 | * Called when an entity reference is detected. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 512 | */ |
| 513 | typedef void (*referenceSAXFunc) (void *ctx, |
| 514 | const xmlChar *name); |
| 515 | /** |
| 516 | * charactersSAXFunc: |
| 517 | * @ctx: the user data (XML parser context) |
| 518 | * @ch: a xmlChar string |
| 519 | * @len: the number of xmlChar |
| 520 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 521 | * Receiving some chars from the parser. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 522 | */ |
| 523 | typedef void (*charactersSAXFunc) (void *ctx, |
| 524 | const xmlChar *ch, |
| 525 | int len); |
| 526 | /** |
| 527 | * ignorableWhitespaceSAXFunc: |
| 528 | * @ctx: the user data (XML parser context) |
| 529 | * @ch: a xmlChar string |
| 530 | * @len: the number of xmlChar |
| 531 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 532 | * Receiving some ignorable whitespaces from the parser. |
| 533 | * UNUSED: by default the DOM building will use characters. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 534 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 535 | typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 536 | const xmlChar *ch, |
| 537 | int len); |
| 538 | /** |
| 539 | * processingInstructionSAXFunc: |
| 540 | * @ctx: the user data (XML parser context) |
| 541 | * @target: the target name |
| 542 | * @data: the PI data's |
| 543 | * |
| 544 | * A processing instruction has been parsed. |
| 545 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 546 | typedef void (*processingInstructionSAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 547 | const xmlChar *target, |
| 548 | const xmlChar *data); |
| 549 | /** |
| 550 | * commentSAXFunc: |
| 551 | * @ctx: the user data (XML parser context) |
| 552 | * @value: the comment content |
| 553 | * |
| 554 | * A comment has been parsed. |
| 555 | */ |
| 556 | typedef void (*commentSAXFunc) (void *ctx, |
| 557 | const xmlChar *value); |
| 558 | /** |
| 559 | * cdataBlockSAXFunc: |
| 560 | * @ctx: the user data (XML parser context) |
| 561 | * @value: The pcdata content |
| 562 | * @len: the block length |
| 563 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 564 | * Called when a pcdata block has been parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 565 | */ |
| 566 | typedef void (*cdataBlockSAXFunc) ( |
| 567 | void *ctx, |
| 568 | const xmlChar *value, |
| 569 | int len); |
| 570 | /** |
| 571 | * warningSAXFunc: |
| 572 | * @ctx: an XML parser context |
| 573 | * @msg: the message to display/transmit |
| 574 | * @...: extra parameters for the message display |
| 575 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 576 | * Display and format a warning messages, callback. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 577 | */ |
| 578 | typedef void (*warningSAXFunc) (void *ctx, |
| 579 | const char *msg, ...); |
| 580 | /** |
| 581 | * errorSAXFunc: |
| 582 | * @ctx: an XML parser context |
| 583 | * @msg: the message to display/transmit |
| 584 | * @...: extra parameters for the message display |
| 585 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 586 | * Display and format an error messages, callback. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 587 | */ |
| 588 | typedef void (*errorSAXFunc) (void *ctx, |
| 589 | const char *msg, ...); |
| 590 | /** |
| 591 | * fatalErrorSAXFunc: |
| 592 | * @ctx: an XML parser context |
| 593 | * @msg: the message to display/transmit |
| 594 | * @...: extra parameters for the message display |
| 595 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 596 | * Display and format fatal error messages, callback. |
Daniel Veillard | 0821b15 | 2002-11-12 20:57:47 +0000 | [diff] [blame] | 597 | * Note: so far fatalError() SAX callbacks are not used, error() |
| 598 | * get all the callbacks for errors. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 599 | */ |
| 600 | typedef void (*fatalErrorSAXFunc) (void *ctx, |
| 601 | const char *msg, ...); |
| 602 | /** |
| 603 | * isStandaloneSAXFunc: |
| 604 | * @ctx: the user data (XML parser context) |
| 605 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 606 | * Is this document tagged standalone? |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 607 | * |
| 608 | * Returns 1 if true |
| 609 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 610 | typedef int (*isStandaloneSAXFunc) (void *ctx); |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 611 | /** |
| 612 | * hasInternalSubsetSAXFunc: |
| 613 | * @ctx: the user data (XML parser context) |
| 614 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 615 | * Does this document has an internal subset. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 616 | * |
| 617 | * Returns 1 if true |
| 618 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 619 | typedef int (*hasInternalSubsetSAXFunc) (void *ctx); |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 620 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 621 | /** |
| 622 | * hasExternalSubsetSAXFunc: |
| 623 | * @ctx: the user data (XML parser context) |
| 624 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 625 | * Does this document has an external subset? |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 626 | * |
| 627 | * Returns 1 if true |
| 628 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 629 | typedef int (*hasExternalSubsetSAXFunc) (void *ctx); |
| 630 | |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 631 | /************************************************************************ |
| 632 | * * |
| 633 | * The SAX version 2 API extensions * |
| 634 | * * |
| 635 | ************************************************************************/ |
| 636 | /** |
| 637 | * XML_SAX2_MAGIC: |
| 638 | * |
| 639 | * Special constant found in SAX2 blocks initialized fields |
| 640 | */ |
| 641 | #define XML_SAX2_MAGIC 0xDEEDBEAF |
| 642 | |
| 643 | /** |
| 644 | * startElementNsSAX2Func: |
| 645 | * @ctx: the user data (XML parser context) |
| 646 | * @localname: the local name of the element |
| 647 | * @prefix: the element namespace prefix if available |
| 648 | * @URI: the element namespace name if available |
| 649 | * @nb_namespaces: number of namespace definitions on that node |
| 650 | * @namespaces: pointer to the array of prefix/URI pairs namespace definitions |
| 651 | * @nb_attributes: the number of attributes on that node |
Daniel Veillard | 07cb822 | 2003-09-10 10:51:05 +0000 | [diff] [blame] | 652 | * @nb_defaulted: the number of defaulted attributes. The defaulted |
| 653 | * ones are at the end of the array |
| 654 | * @attributes: pointer to the array of (localname/prefix/URI/value/end) |
| 655 | * attribute values. |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 656 | * |
| 657 | * SAX2 callback when an element start has been detected by the parser. |
| 658 | * It provides the namespace informations for the element, as well as |
| 659 | * the new namespace declarations on the element. |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 660 | */ |
| 661 | |
| 662 | typedef void (*startElementNsSAX2Func) (void *ctx, |
| 663 | const xmlChar *localname, |
| 664 | const xmlChar *prefix, |
| 665 | const xmlChar *URI, |
| 666 | int nb_namespaces, |
| 667 | const xmlChar **namespaces, |
Daniel Veillard | 07cb822 | 2003-09-10 10:51:05 +0000 | [diff] [blame] | 668 | int nb_attributes, |
| 669 | int nb_defaulted, |
| 670 | const xmlChar **attributes); |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 671 | |
| 672 | /** |
| 673 | * endElementNsSAX2Func: |
| 674 | * @ctx: the user data (XML parser context) |
| 675 | * @localname: the local name of the element |
| 676 | * @prefix: the element namespace prefix if available |
| 677 | * @URI: the element namespace name if available |
| 678 | * |
| 679 | * SAX2 callback when an element end has been detected by the parser. |
| 680 | * It provides the namespace informations for the element. |
| 681 | */ |
| 682 | |
| 683 | typedef void (*endElementNsSAX2Func) (void *ctx, |
| 684 | const xmlChar *localname, |
| 685 | const xmlChar *prefix, |
| 686 | const xmlChar *URI); |
| 687 | |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 688 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 689 | struct _xmlSAXHandler { |
| 690 | internalSubsetSAXFunc internalSubset; |
| 691 | isStandaloneSAXFunc isStandalone; |
| 692 | hasInternalSubsetSAXFunc hasInternalSubset; |
| 693 | hasExternalSubsetSAXFunc hasExternalSubset; |
| 694 | resolveEntitySAXFunc resolveEntity; |
| 695 | getEntitySAXFunc getEntity; |
| 696 | entityDeclSAXFunc entityDecl; |
| 697 | notationDeclSAXFunc notationDecl; |
| 698 | attributeDeclSAXFunc attributeDecl; |
| 699 | elementDeclSAXFunc elementDecl; |
| 700 | unparsedEntityDeclSAXFunc unparsedEntityDecl; |
| 701 | setDocumentLocatorSAXFunc setDocumentLocator; |
| 702 | startDocumentSAXFunc startDocument; |
| 703 | endDocumentSAXFunc endDocument; |
| 704 | startElementSAXFunc startElement; |
| 705 | endElementSAXFunc endElement; |
| 706 | referenceSAXFunc reference; |
| 707 | charactersSAXFunc characters; |
| 708 | ignorableWhitespaceSAXFunc ignorableWhitespace; |
| 709 | processingInstructionSAXFunc processingInstruction; |
| 710 | commentSAXFunc comment; |
| 711 | warningSAXFunc warning; |
| 712 | errorSAXFunc error; |
Daniel Veillard | 0821b15 | 2002-11-12 20:57:47 +0000 | [diff] [blame] | 713 | fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 714 | getParameterEntitySAXFunc getParameterEntity; |
| 715 | cdataBlockSAXFunc cdataBlock; |
| 716 | externalSubsetSAXFunc externalSubset; |
Daniel Veillard | 07cb822 | 2003-09-10 10:51:05 +0000 | [diff] [blame] | 717 | unsigned int initialized; |
Daniel Veillard | 1af9a41 | 2003-08-20 22:54:39 +0000 | [diff] [blame] | 718 | /* The following fields are extensions available only on version 2 */ |
| 719 | void *_private; |
| 720 | startElementNsSAX2Func startElementNs; |
| 721 | endElementNsSAX2Func endElementNs; |
Daniel Veillard | 659e71e | 2003-10-10 14:10:40 +0000 | [diff] [blame] | 722 | xmlStructuredErrorFunc serror; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 723 | }; |
| 724 | |
Daniel Veillard | 9ee35f3 | 2003-09-28 00:19:54 +0000 | [diff] [blame] | 725 | /* |
| 726 | * SAX Version 1 |
| 727 | */ |
| 728 | typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; |
| 729 | typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; |
| 730 | struct _xmlSAXHandlerV1 { |
| 731 | internalSubsetSAXFunc internalSubset; |
| 732 | isStandaloneSAXFunc isStandalone; |
| 733 | hasInternalSubsetSAXFunc hasInternalSubset; |
| 734 | hasExternalSubsetSAXFunc hasExternalSubset; |
| 735 | resolveEntitySAXFunc resolveEntity; |
| 736 | getEntitySAXFunc getEntity; |
| 737 | entityDeclSAXFunc entityDecl; |
| 738 | notationDeclSAXFunc notationDecl; |
| 739 | attributeDeclSAXFunc attributeDecl; |
| 740 | elementDeclSAXFunc elementDecl; |
| 741 | unparsedEntityDeclSAXFunc unparsedEntityDecl; |
| 742 | setDocumentLocatorSAXFunc setDocumentLocator; |
| 743 | startDocumentSAXFunc startDocument; |
| 744 | endDocumentSAXFunc endDocument; |
| 745 | startElementSAXFunc startElement; |
| 746 | endElementSAXFunc endElement; |
| 747 | referenceSAXFunc reference; |
| 748 | charactersSAXFunc characters; |
| 749 | ignorableWhitespaceSAXFunc ignorableWhitespace; |
| 750 | processingInstructionSAXFunc processingInstruction; |
| 751 | commentSAXFunc comment; |
| 752 | warningSAXFunc warning; |
| 753 | errorSAXFunc error; |
| 754 | fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ |
| 755 | getParameterEntitySAXFunc getParameterEntity; |
| 756 | cdataBlockSAXFunc cdataBlock; |
| 757 | externalSubsetSAXFunc externalSubset; |
| 758 | unsigned int initialized; |
| 759 | }; |
| 760 | |
| 761 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 762 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 763 | * xmlExternalEntityLoader: |
| 764 | * @URL: The System ID of the resource requested |
| 765 | * @ID: The Public ID of the resource requested |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 766 | * @context: the XML parser context |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 767 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 768 | * External entity loaders types. |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 769 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 770 | * Returns the entity input parser. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 771 | */ |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 772 | typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, |
| 773 | const char *ID, |
| 774 | xmlParserCtxtPtr context); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 775 | |
Daniel Veillard | 6c4ffaf | 2002-02-11 08:54:05 +0000 | [diff] [blame] | 776 | #ifdef __cplusplus |
| 777 | } |
| 778 | #endif |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 779 | |
Daniel Veillard | 6c4ffaf | 2002-02-11 08:54:05 +0000 | [diff] [blame] | 780 | #include <libxml/encoding.h> |
| 781 | #include <libxml/xmlIO.h> |
| 782 | #include <libxml/globals.h> |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 783 | |
Daniel Veillard | 6c4ffaf | 2002-02-11 08:54:05 +0000 | [diff] [blame] | 784 | #ifdef __cplusplus |
| 785 | extern "C" { |
| 786 | #endif |
| 787 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 788 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 789 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 790 | * Init/Cleanup |
| 791 | */ |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 792 | XMLPUBFUN void XMLCALL |
| 793 | xmlInitParser (void); |
| 794 | XMLPUBFUN void XMLCALL |
| 795 | xmlCleanupParser (void); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 796 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 797 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 798 | * Input functions |
| 799 | */ |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 800 | XMLPUBFUN int XMLCALL |
| 801 | xmlParserInputRead (xmlParserInputPtr in, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 802 | int len); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 803 | XMLPUBFUN int XMLCALL |
| 804 | xmlParserInputGrow (xmlParserInputPtr in, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 805 | int len); |
| 806 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 807 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 808 | * xmlChar handling |
| 809 | */ |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 810 | XMLPUBFUN xmlChar * XMLCALL |
| 811 | xmlStrdup (const xmlChar *cur); |
| 812 | XMLPUBFUN xmlChar * XMLCALL |
| 813 | xmlStrndup (const xmlChar *cur, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 814 | int len); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 815 | XMLPUBFUN xmlChar * XMLCALL |
| 816 | xmlCharStrndup (const char *cur, |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 817 | int len); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 818 | XMLPUBFUN xmlChar * XMLCALL |
| 819 | xmlCharStrdup (const char *cur); |
| 820 | XMLPUBFUN xmlChar * XMLCALL |
| 821 | xmlStrsub (const xmlChar *str, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 822 | int start, |
| 823 | int len); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 824 | XMLPUBFUN const xmlChar * XMLCALL |
| 825 | xmlStrchr (const xmlChar *str, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 826 | xmlChar val); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 827 | XMLPUBFUN const xmlChar * XMLCALL |
| 828 | xmlStrstr (const xmlChar *str, |
Daniel Veillard | 7704473 | 2001-06-29 21:31:07 +0000 | [diff] [blame] | 829 | const xmlChar *val); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 830 | XMLPUBFUN const xmlChar * XMLCALL |
| 831 | xmlStrcasestr (const xmlChar *str, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 832 | xmlChar *val); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 833 | XMLPUBFUN int XMLCALL |
| 834 | xmlStrcmp (const xmlChar *str1, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 835 | const xmlChar *str2); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 836 | XMLPUBFUN int XMLCALL |
| 837 | xmlStrncmp (const xmlChar *str1, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 838 | const xmlChar *str2, |
| 839 | int len); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 840 | XMLPUBFUN int XMLCALL |
| 841 | xmlStrcasecmp (const xmlChar *str1, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 842 | const xmlChar *str2); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 843 | XMLPUBFUN int XMLCALL |
| 844 | xmlStrncasecmp (const xmlChar *str1, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 845 | const xmlChar *str2, |
| 846 | int len); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 847 | XMLPUBFUN int XMLCALL |
| 848 | xmlStrEqual (const xmlChar *str1, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 849 | const xmlChar *str2); |
Daniel Veillard | 07cb822 | 2003-09-10 10:51:05 +0000 | [diff] [blame] | 850 | XMLPUBFUN int XMLCALL |
| 851 | xmlStrQEqual (const xmlChar *pref, |
| 852 | const xmlChar *name, |
| 853 | const xmlChar *str); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 854 | XMLPUBFUN int XMLCALL |
| 855 | xmlStrlen (const xmlChar *str); |
| 856 | XMLPUBFUN xmlChar * XMLCALL |
| 857 | xmlStrcat (xmlChar *cur, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 858 | const xmlChar *add); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 859 | XMLPUBFUN xmlChar * XMLCALL |
| 860 | xmlStrncat (xmlChar *cur, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 861 | const xmlChar *add, |
| 862 | int len); |
| 863 | |
Aleksey Sanin | e7acf43 | 2003-10-02 20:05:27 +0000 | [diff] [blame] | 864 | XMLPUBFUN int XMLCALL |
| 865 | xmlStrPrintf (xmlChar *buf, |
| 866 | int len, |
| 867 | const xmlChar *msg, |
| 868 | ...); |
| 869 | |
Aleksey Sanin | b5a46da | 2003-10-29 15:51:17 +0000 | [diff] [blame] | 870 | XMLPUBFUN int XMLCALL |
| 871 | xmlStrVPrintf (xmlChar *buf, |
| 872 | int len, |
| 873 | const xmlChar *msg, |
| 874 | va_list ap); |
| 875 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 876 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 877 | * Basic parsing Interfaces |
| 878 | */ |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 879 | XMLPUBFUN xmlDocPtr XMLCALL |
| 880 | xmlParseDoc (xmlChar *cur); |
| 881 | XMLPUBFUN xmlDocPtr XMLCALL |
| 882 | xmlParseMemory (const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 883 | int size); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 884 | XMLPUBFUN xmlDocPtr XMLCALL |
| 885 | xmlParseFile (const char *filename); |
| 886 | XMLPUBFUN int XMLCALL |
| 887 | xmlSubstituteEntitiesDefault(int val); |
| 888 | XMLPUBFUN int XMLCALL |
| 889 | xmlKeepBlanksDefault (int val); |
| 890 | XMLPUBFUN void XMLCALL |
| 891 | xmlStopParser (xmlParserCtxtPtr ctxt); |
| 892 | XMLPUBFUN int XMLCALL |
| 893 | xmlPedanticParserDefault(int val); |
| 894 | XMLPUBFUN int XMLCALL |
| 895 | xmlLineNumbersDefault (int val); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 896 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 897 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 898 | * Recovery mode |
| 899 | */ |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 900 | XMLPUBFUN xmlDocPtr XMLCALL |
| 901 | xmlRecoverDoc (xmlChar *cur); |
| 902 | XMLPUBFUN xmlDocPtr XMLCALL |
| 903 | xmlRecoverMemory (const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 904 | int size); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 905 | XMLPUBFUN xmlDocPtr XMLCALL |
| 906 | xmlRecoverFile (const char *filename); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 907 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 908 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 909 | * Less common routines and SAX interfaces |
| 910 | */ |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 911 | XMLPUBFUN int XMLCALL |
| 912 | xmlParseDocument (xmlParserCtxtPtr ctxt); |
| 913 | XMLPUBFUN int XMLCALL |
| 914 | xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); |
| 915 | XMLPUBFUN xmlDocPtr XMLCALL |
| 916 | xmlSAXParseDoc (xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 917 | xmlChar *cur, |
| 918 | int recovery); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 919 | XMLPUBFUN int XMLCALL |
| 920 | xmlSAXUserParseFile (xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 921 | void *user_data, |
| 922 | const char *filename); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 923 | XMLPUBFUN int XMLCALL |
| 924 | xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 925 | void *user_data, |
Daniel Veillard | fd7ddca | 2001-05-16 10:57:35 +0000 | [diff] [blame] | 926 | const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 927 | int size); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 928 | XMLPUBFUN xmlDocPtr XMLCALL |
| 929 | xmlSAXParseMemory (xmlSAXHandlerPtr sax, |
Daniel Veillard | 50822cb | 2001-07-26 20:05:51 +0000 | [diff] [blame] | 930 | const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 931 | int size, |
| 932 | int recovery); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 933 | XMLPUBFUN xmlDocPtr XMLCALL |
| 934 | xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, |
Daniel Veillard | 8606bbb | 2002-11-12 12:36:52 +0000 | [diff] [blame] | 935 | const char *buffer, |
| 936 | int size, |
| 937 | int recovery, |
| 938 | void *data); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 939 | XMLPUBFUN xmlDocPtr XMLCALL |
| 940 | xmlSAXParseFile (xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 941 | const char *filename, |
| 942 | int recovery); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 943 | XMLPUBFUN xmlDocPtr XMLCALL |
| 944 | xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, |
Daniel Veillard | a293c32 | 2001-10-02 13:54:14 +0000 | [diff] [blame] | 945 | const char *filename, |
| 946 | int recovery, |
| 947 | void *data); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 948 | XMLPUBFUN xmlDocPtr XMLCALL |
| 949 | xmlSAXParseEntity (xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 950 | const char *filename); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 951 | XMLPUBFUN xmlDocPtr XMLCALL |
| 952 | xmlParseEntity (const char *filename); |
| 953 | XMLPUBFUN xmlDtdPtr XMLCALL |
| 954 | xmlParseDTD (const xmlChar *ExternalID, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 955 | const xmlChar *SystemID); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 956 | XMLPUBFUN xmlDtdPtr XMLCALL |
| 957 | xmlSAXParseDTD (xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 958 | const xmlChar *ExternalID, |
| 959 | const xmlChar *SystemID); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 960 | XMLPUBFUN xmlDtdPtr XMLCALL |
| 961 | xmlIOParseDTD (xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 962 | xmlParserInputBufferPtr input, |
| 963 | xmlCharEncoding enc); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 964 | XMLPUBFUN int XMLCALL |
| 965 | xmlParseBalancedChunkMemory(xmlDocPtr doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 966 | xmlSAXHandlerPtr sax, |
| 967 | void *user_data, |
| 968 | int depth, |
| 969 | const xmlChar *string, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 970 | xmlNodePtr *lst); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 971 | XMLPUBFUN int XMLCALL |
| 972 | xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, |
Daniel Veillard | 58e44c9 | 2002-08-02 22:19:49 +0000 | [diff] [blame] | 973 | xmlSAXHandlerPtr sax, |
| 974 | void *user_data, |
| 975 | int depth, |
| 976 | const xmlChar *string, |
| 977 | xmlNodePtr *lst, |
| 978 | int recover); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 979 | XMLPUBFUN int XMLCALL |
| 980 | xmlParseExternalEntity (xmlDocPtr doc, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 981 | xmlSAXHandlerPtr sax, |
| 982 | void *user_data, |
| 983 | int depth, |
| 984 | const xmlChar *URL, |
| 985 | const xmlChar *ID, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 986 | xmlNodePtr *lst); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 987 | XMLPUBFUN int XMLCALL |
| 988 | xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 989 | const xmlChar *URL, |
| 990 | const xmlChar *ID, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 991 | xmlNodePtr *lst); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 992 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 993 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 994 | * Parser contexts handling. |
| 995 | */ |
Daniel Veillard | 2b8c4a1 | 2003-10-02 22:28:19 +0000 | [diff] [blame] | 996 | XMLPUBFUN xmlParserCtxtPtr XMLCALL |
| 997 | xmlNewParserCtxt (void); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 998 | XMLPUBFUN int XMLCALL |
| 999 | xmlInitParserCtxt (xmlParserCtxtPtr ctxt); |
| 1000 | XMLPUBFUN void XMLCALL |
| 1001 | xmlClearParserCtxt (xmlParserCtxtPtr ctxt); |
| 1002 | XMLPUBFUN void XMLCALL |
| 1003 | xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); |
| 1004 | XMLPUBFUN void XMLCALL |
| 1005 | xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1006 | const xmlChar* buffer, |
Daniel Veillard | 963d2ae | 2002-01-20 22:08:18 +0000 | [diff] [blame] | 1007 | const char *filename); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1008 | XMLPUBFUN xmlParserCtxtPtr XMLCALL |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1009 | xmlCreateDocParserCtxt (const xmlChar *cur); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1010 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 1011 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1012 | * Reading/setting optional parsing features. |
| 1013 | */ |
| 1014 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1015 | XMLPUBFUN int XMLCALL |
| 1016 | xmlGetFeaturesList (int *len, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1017 | const char **result); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1018 | XMLPUBFUN int XMLCALL |
| 1019 | xmlGetFeature (xmlParserCtxtPtr ctxt, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1020 | const char *name, |
| 1021 | void *result); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1022 | XMLPUBFUN int XMLCALL |
| 1023 | xmlSetFeature (xmlParserCtxtPtr ctxt, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1024 | const char *name, |
| 1025 | void *value); |
| 1026 | |
Daniel Veillard | 73b013f | 2003-09-30 12:36:01 +0000 | [diff] [blame] | 1027 | #ifdef LIBXML_PUSH_ENABLED |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 1028 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 1029 | * Interfaces for the Push mode. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1030 | */ |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1031 | XMLPUBFUN xmlParserCtxtPtr XMLCALL |
| 1032 | xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1033 | void *user_data, |
| 1034 | const char *chunk, |
| 1035 | int size, |
| 1036 | const char *filename); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1037 | XMLPUBFUN int XMLCALL |
| 1038 | xmlParseChunk (xmlParserCtxtPtr ctxt, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1039 | const char *chunk, |
| 1040 | int size, |
| 1041 | int terminate); |
Daniel Veillard | 73b013f | 2003-09-30 12:36:01 +0000 | [diff] [blame] | 1042 | #endif /* LIBXML_PUSH_ENABLED */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1043 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 1044 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 1045 | * Special I/O mode. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1046 | */ |
| 1047 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1048 | XMLPUBFUN xmlParserCtxtPtr XMLCALL |
| 1049 | xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1050 | void *user_data, |
| 1051 | xmlInputReadCallback ioread, |
| 1052 | xmlInputCloseCallback ioclose, |
| 1053 | void *ioctx, |
| 1054 | xmlCharEncoding enc); |
| 1055 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1056 | XMLPUBFUN xmlParserInputPtr XMLCALL |
| 1057 | xmlNewIOInputStream (xmlParserCtxtPtr ctxt, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1058 | xmlParserInputBufferPtr input, |
| 1059 | xmlCharEncoding enc); |
| 1060 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 1061 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 1062 | * Node infos. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1063 | */ |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1064 | XMLPUBFUN const xmlParserNodeInfo* XMLCALL |
Daniel Veillard | 963d2ae | 2002-01-20 22:08:18 +0000 | [diff] [blame] | 1065 | xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt, |
| 1066 | const xmlNodePtr node); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1067 | XMLPUBFUN void XMLCALL |
| 1068 | xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
| 1069 | XMLPUBFUN void XMLCALL |
| 1070 | xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
| 1071 | XMLPUBFUN unsigned long XMLCALL |
| 1072 | xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, |
Daniel Veillard | 963d2ae | 2002-01-20 22:08:18 +0000 | [diff] [blame] | 1073 | const xmlNodePtr node); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1074 | XMLPUBFUN void XMLCALL |
| 1075 | xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, |
Daniel Veillard | 963d2ae | 2002-01-20 22:08:18 +0000 | [diff] [blame] | 1076 | const xmlParserNodeInfoPtr info); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1077 | |
| 1078 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 1079 | * External entities handling actually implemented in xmlIO. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1080 | */ |
| 1081 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1082 | XMLPUBFUN void XMLCALL |
| 1083 | xmlSetExternalEntityLoader(xmlExternalEntityLoader f); |
| 1084 | XMLPUBFUN xmlExternalEntityLoader XMLCALL |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1085 | xmlGetExternalEntityLoader(void); |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 1086 | XMLPUBFUN xmlParserInputPtr XMLCALL |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1087 | xmlLoadExternalEntity (const char *URL, |
| 1088 | const char *ID, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 1089 | xmlParserCtxtPtr ctxt); |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1090 | /* |
| 1091 | * New set of simpler/more flexible APIs |
| 1092 | */ |
| 1093 | /** |
| 1094 | * xmlParserOption: |
| 1095 | * |
| 1096 | * This is the set of XML parser options that can be passed down |
| 1097 | * to the xmlReadDoc() and similar calls. |
| 1098 | */ |
| 1099 | typedef enum { |
| 1100 | XML_PARSE_RECOVER = 1<<0, /* recover on errors */ |
| 1101 | XML_PARSE_NOENT = 1<<1, /* substitute entities */ |
| 1102 | XML_PARSE_DTDLOAD = 1<<2, /* load the external subset */ |
| 1103 | XML_PARSE_DTDATTR = 1<<3, /* default DTD attributes */ |
| 1104 | XML_PARSE_DTDVALID = 1<<4, /* validate with the DTD */ |
| 1105 | XML_PARSE_NOERROR = 1<<5, /* suppress error reports */ |
| 1106 | XML_PARSE_NOWARNING = 1<<6, /* suppress warning reports */ |
| 1107 | XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */ |
| 1108 | XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */ |
| 1109 | XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */ |
| 1110 | XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */ |
Daniel Veillard | e96a2a4 | 2003-09-24 21:23:56 +0000 | [diff] [blame] | 1111 | XML_PARSE_NONET = 1<<11,/* Forbid network access */ |
Daniel Veillard | 9475a35 | 2003-09-26 12:47:50 +0000 | [diff] [blame] | 1112 | XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionnary */ |
| 1113 | XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */ |
| 1114 | XML_PARSE_NOCDATA = 1<<14 /* merge CDATA as text nodes */ |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1115 | } xmlParserOption; |
| 1116 | |
| 1117 | XMLPUBFUN void XMLCALL |
| 1118 | xmlCtxtReset (xmlParserCtxtPtr ctxt); |
| 1119 | XMLPUBFUN int XMLCALL |
Daniel Veillard | 9ba8e38 | 2003-10-28 21:31:45 +0000 | [diff] [blame] | 1120 | xmlCtxtResetPush (xmlParserCtxtPtr ctxt, |
| 1121 | const char *chunk, |
| 1122 | int size, |
| 1123 | const char *filename, |
| 1124 | const char *encoding); |
| 1125 | XMLPUBFUN int XMLCALL |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1126 | xmlCtxtUseOptions (xmlParserCtxtPtr ctxt, |
| 1127 | int options); |
| 1128 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1129 | xmlReadDoc (const xmlChar *cur, |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1130 | const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1131 | const char *encoding, |
| 1132 | int options); |
| 1133 | XMLPUBFUN xmlDocPtr XMLCALL |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1134 | xmlReadFile (const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1135 | const char *encoding, |
| 1136 | int options); |
| 1137 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1138 | xmlReadMemory (const char *buffer, |
| 1139 | int size, |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1140 | const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1141 | const char *encoding, |
| 1142 | int options); |
| 1143 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1144 | xmlReadFd (int fd, |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1145 | const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1146 | const char *encoding, |
| 1147 | int options); |
| 1148 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1149 | xmlReadIO (xmlInputReadCallback ioread, |
| 1150 | xmlInputCloseCallback ioclose, |
| 1151 | void *ioctx, |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1152 | const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1153 | const char *encoding, |
| 1154 | int options); |
| 1155 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1156 | xmlCtxtReadDoc (xmlParserCtxtPtr ctxt, |
| 1157 | const xmlChar *cur, |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1158 | const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1159 | const char *encoding, |
| 1160 | int options); |
| 1161 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1162 | xmlCtxtReadFile (xmlParserCtxtPtr ctxt, |
| 1163 | const char *filename, |
| 1164 | const char *encoding, |
| 1165 | int options); |
| 1166 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1167 | xmlCtxtReadMemory (xmlParserCtxtPtr ctxt, |
| 1168 | const char *buffer, |
| 1169 | int size, |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1170 | const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1171 | const char *encoding, |
| 1172 | int options); |
| 1173 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1174 | xmlCtxtReadFd (xmlParserCtxtPtr ctxt, |
| 1175 | int fd, |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1176 | const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1177 | const char *encoding, |
| 1178 | int options); |
| 1179 | XMLPUBFUN xmlDocPtr XMLCALL |
| 1180 | xmlCtxtReadIO (xmlParserCtxtPtr ctxt, |
| 1181 | xmlInputReadCallback ioread, |
| 1182 | xmlInputCloseCallback ioclose, |
| 1183 | void *ioctx, |
Daniel Veillard | 60942de | 2003-09-25 21:05:58 +0000 | [diff] [blame] | 1184 | const char *URL, |
Daniel Veillard | 16fa96c | 2003-09-23 21:50:54 +0000 | [diff] [blame] | 1185 | const char *encoding, |
| 1186 | int options); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1187 | |
| 1188 | #ifdef __cplusplus |
| 1189 | } |
| 1190 | #endif |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1191 | #endif /* __XML_PARSER_H__ */ |
| 1192 | |