Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * parser.h : Interfaces, constants and types related to the XML parser. |
| 3 | * |
| 4 | * See Copyright for the status of this software. |
| 5 | * |
Daniel Veillard | c5d6434 | 2001-06-24 12:13:24 +0000 | [diff] [blame] | 6 | * daniel@veillard.com |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #ifndef __XML_PARSER_H__ |
| 10 | #define __XML_PARSER_H__ |
| 11 | |
| 12 | #include <libxml/tree.h> |
| 13 | #include <libxml/valid.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 14 | #include <libxml/entities.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif |
| 19 | |
Daniel Veillard | 5e2dace | 2001-07-18 19:30:27 +0000 | [diff] [blame] | 20 | /** |
| 21 | * XML_DEFAULT_VERSION: |
| 22 | * |
| 23 | * The default version of XML used: 1.0 |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 24 | */ |
| 25 | #define XML_DEFAULT_VERSION "1.0" |
| 26 | |
| 27 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 28 | * xmlParserInput: |
| 29 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 30 | * An xmlParserInput is an input flow for the XML processor. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 31 | * Each entity parsed is associated an xmlParserInput (except the |
| 32 | * few predefined ones). This is the case both for internal entities |
| 33 | * - in which case the flow is already completely in memory - or |
| 34 | * external entities - in which case we use the buf structure for |
| 35 | * progressive reading and I18N conversions to the internal UTF-8 format. |
| 36 | */ |
| 37 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 38 | /** |
| 39 | * xmlParserInputDeallocate: |
| 40 | * @str: the string to deallocate |
| 41 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 42 | * Callback for freeing some parser input allocations. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 43 | */ |
| 44 | typedef void (* xmlParserInputDeallocate)(xmlChar *str); |
Daniel Veillard | 5e2dace | 2001-07-18 19:30:27 +0000 | [diff] [blame] | 45 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 46 | struct _xmlParserInput { |
| 47 | /* Input buffer */ |
| 48 | xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ |
| 49 | |
| 50 | const char *filename; /* The file analyzed, if any */ |
Daniel Veillard | 60087f3 | 2001-10-10 09:45:09 +0000 | [diff] [blame] | 51 | const char *directory; /* the directory/base of the file */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 52 | const xmlChar *base; /* Base of the array to parse */ |
| 53 | const xmlChar *cur; /* Current char being parsed */ |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 54 | const xmlChar *end; /* end of the array to parse */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 55 | int length; /* length if known */ |
| 56 | int line; /* Current line */ |
| 57 | int col; /* Current column */ |
Daniel Veillard | 3e59fc5 | 2003-04-18 12:34:58 +0000 | [diff] [blame^] | 58 | /* |
| 59 | * NOTE: consumed is only tested for equality in the parser code, |
| 60 | * so even if there is an overflow this should not give troubles |
| 61 | * for parsing very large instances. |
| 62 | */ |
| 63 | unsigned long consumed; /* How many xmlChars already consumed */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 64 | xmlParserInputDeallocate free; /* function to deallocate the base */ |
| 65 | const xmlChar *encoding; /* the encoding string for entity */ |
| 66 | const xmlChar *version; /* the version string for entity */ |
| 67 | int standalone; /* Was that entity marked standalone */ |
| 68 | }; |
| 69 | |
| 70 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 71 | * xmlParserNodeInfo: |
| 72 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 73 | * 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] | 74 | * place in the file they were detected. |
| 75 | * NOTE: This is off by default and not very well tested. |
| 76 | */ |
| 77 | typedef struct _xmlParserNodeInfo xmlParserNodeInfo; |
| 78 | typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; |
| 79 | |
| 80 | struct _xmlParserNodeInfo { |
| 81 | const struct _xmlNode* node; |
| 82 | /* Position & line # that text that created the node begins & ends on */ |
| 83 | unsigned long begin_pos; |
| 84 | unsigned long begin_line; |
| 85 | unsigned long end_pos; |
| 86 | unsigned long end_line; |
| 87 | }; |
| 88 | |
| 89 | typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; |
| 90 | typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; |
| 91 | struct _xmlParserNodeInfoSeq { |
| 92 | unsigned long maximum; |
| 93 | unsigned long length; |
| 94 | xmlParserNodeInfo* buffer; |
| 95 | }; |
| 96 | |
| 97 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 98 | * xmlParserInputState: |
| 99 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 100 | * The parser is now working also as a state based parser. |
| 101 | * The recursive one use the state info for entities processing. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 102 | */ |
| 103 | typedef enum { |
| 104 | XML_PARSER_EOF = -1, /* nothing is to be parsed */ |
| 105 | XML_PARSER_START = 0, /* nothing has been parsed */ |
| 106 | XML_PARSER_MISC, /* Misc* before int subset */ |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 107 | XML_PARSER_PI, /* Within a processing instruction */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 108 | XML_PARSER_DTD, /* within some DTD content */ |
| 109 | XML_PARSER_PROLOG, /* Misc* after internal subset */ |
| 110 | XML_PARSER_COMMENT, /* within a comment */ |
| 111 | XML_PARSER_START_TAG, /* within a start tag */ |
| 112 | XML_PARSER_CONTENT, /* within the content */ |
| 113 | XML_PARSER_CDATA_SECTION, /* within a CDATA section */ |
| 114 | XML_PARSER_END_TAG, /* within a closing tag */ |
| 115 | XML_PARSER_ENTITY_DECL, /* within an entity declaration */ |
| 116 | XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ |
| 117 | XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ |
| 118 | XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ |
| 119 | XML_PARSER_EPILOG, /* the Misc* after the last end tag */ |
Daniel Veillard | 4a7ae50 | 2002-02-18 19:18:17 +0000 | [diff] [blame] | 120 | XML_PARSER_IGNORE, /* within an IGNORED section */ |
| 121 | XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 122 | } xmlParserInputState; |
| 123 | |
| 124 | /** |
Daniel Veillard | d16df9f | 2001-05-23 13:44:21 +0000 | [diff] [blame] | 125 | * XML_DETECT_IDS: |
| 126 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 127 | * Bit in the loadsubset context field to tell to do ID/REFs lookups. |
| 128 | * Use it to initialize xmlLoadExtDtdDefaultValue. |
Daniel Veillard | d16df9f | 2001-05-23 13:44:21 +0000 | [diff] [blame] | 129 | */ |
| 130 | #define XML_DETECT_IDS 2 |
| 131 | |
| 132 | /** |
| 133 | * XML_COMPLETE_ATTRS: |
| 134 | * |
| 135 | * Bit in the loadsubset context field to tell to do complete the |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 136 | * elements attributes lists with the ones defaulted from the DTDs. |
| 137 | * Use it to initialize xmlLoadExtDtdDefaultValue. |
Daniel Veillard | d16df9f | 2001-05-23 13:44:21 +0000 | [diff] [blame] | 138 | */ |
| 139 | #define XML_COMPLETE_ATTRS 4 |
| 140 | |
| 141 | /** |
Daniel Veillard | ef8dd7b | 2003-03-23 12:02:56 +0000 | [diff] [blame] | 142 | * XML_SKIP_IDS: |
| 143 | * |
| 144 | * Bit in the loadsubset context field to tell to not do ID/REFs registration. |
| 145 | * Used to initialize xmlLoadExtDtdDefaultValue in some special cases. |
| 146 | */ |
| 147 | #define XML_SKIP_IDS 8 |
| 148 | |
| 149 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 150 | * xmlParserCtxt: |
| 151 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 152 | * The parser context. |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 153 | * NOTE This doesn't completely define the parser state, the (current ?) |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 154 | * design of the parser uses recursive function calls since this allow |
| 155 | * and easy mapping from the production rules of the specification |
| 156 | * to the actual code. The drawback is that the actual function call |
| 157 | * also reflect the parser state. However most of the parsing routines |
| 158 | * takes as the only argument the parser context pointer, so migrating |
| 159 | * to a state based parser for progressive parsing shouldn't be too hard. |
| 160 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 161 | struct _xmlParserCtxt { |
| 162 | struct _xmlSAXHandler *sax; /* The SAX handler */ |
| 163 | void *userData; /* For SAX interface only, used by DOM build */ |
| 164 | xmlDocPtr myDoc; /* the document being built */ |
| 165 | int wellFormed; /* is the document well formed */ |
| 166 | int replaceEntities; /* shall we replace entities ? */ |
| 167 | const xmlChar *version; /* the XML version string */ |
| 168 | const xmlChar *encoding; /* the declared encoding, if any */ |
| 169 | int standalone; /* standalone document */ |
| 170 | int html; /* an HTML(1)/Docbook(2) document */ |
| 171 | |
| 172 | /* Input stream stack */ |
| 173 | xmlParserInputPtr input; /* Current input stream */ |
| 174 | int inputNr; /* Number of current input streams */ |
| 175 | int inputMax; /* Max number of input streams */ |
| 176 | xmlParserInputPtr *inputTab; /* stack of inputs */ |
| 177 | |
| 178 | /* Node analysis stack only used for DOM building */ |
| 179 | xmlNodePtr node; /* Current parsed Node */ |
| 180 | int nodeNr; /* Depth of the parsing stack */ |
| 181 | int nodeMax; /* Max depth of the parsing stack */ |
| 182 | xmlNodePtr *nodeTab; /* array of nodes */ |
| 183 | |
| 184 | int record_info; /* Whether node info should be kept */ |
| 185 | xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ |
| 186 | |
| 187 | int errNo; /* error code */ |
| 188 | |
| 189 | int hasExternalSubset; /* reference and external subset */ |
| 190 | int hasPErefs; /* the internal subset has PE refs */ |
| 191 | int external; /* are we parsing an external entity */ |
| 192 | |
| 193 | int valid; /* is the document valid */ |
| 194 | int validate; /* shall we try to validate ? */ |
| 195 | xmlValidCtxt vctxt; /* The validity context */ |
| 196 | |
| 197 | xmlParserInputState instate; /* current type of input */ |
| 198 | int token; /* next char look-ahead */ |
| 199 | |
| 200 | char *directory; /* the data directory */ |
| 201 | |
| 202 | /* Node name stack */ |
| 203 | xmlChar *name; /* Current parsed Node */ |
| 204 | int nameNr; /* Depth of the parsing stack */ |
| 205 | int nameMax; /* Max depth of the parsing stack */ |
| 206 | xmlChar * *nameTab; /* array of nodes */ |
| 207 | |
| 208 | long nbChars; /* number of xmlChar processed */ |
| 209 | long checkIndex; /* used by progressive parsing lookup */ |
| 210 | int keepBlanks; /* ugly but ... */ |
| 211 | int disableSAX; /* SAX callbacks are disabled */ |
| 212 | int inSubset; /* Parsing is in int 1/ext 2 subset */ |
| 213 | xmlChar * intSubName; /* name of subset */ |
| 214 | xmlChar * extSubURI; /* URI of external subset */ |
| 215 | xmlChar * extSubSystem; /* SYSTEM ID of external subset */ |
| 216 | |
| 217 | /* xml:space values */ |
| 218 | int * space; /* Should the parser preserve spaces */ |
| 219 | int spaceNr; /* Depth of the parsing stack */ |
| 220 | int spaceMax; /* Max depth of the parsing stack */ |
| 221 | int * spaceTab; /* array of space infos */ |
| 222 | |
| 223 | int depth; /* to prevent entity substitution loops */ |
| 224 | xmlParserInputPtr entity; /* used to check entities boundaries */ |
| 225 | int charset; /* encoding of the in-memory content |
| 226 | actually an xmlCharEncoding */ |
| 227 | int nodelen; /* Those two fields are there to */ |
| 228 | int nodemem; /* Speed up large node parsing */ |
| 229 | int pedantic; /* signal pedantic warnings */ |
| 230 | void *_private; /* For user data, libxml won't touch it */ |
| 231 | |
| 232 | int loadsubset; /* should the external subset be loaded */ |
Daniel Veillard | d9bad13 | 2001-07-23 19:39:43 +0000 | [diff] [blame] | 233 | int linenumbers; /* set line number in element content */ |
Daniel Veillard | 5d90b6c | 2001-08-22 14:29:45 +0000 | [diff] [blame] | 234 | void *catalogs; /* document's own catalog */ |
Daniel Veillard | dad3f68 | 2002-11-17 16:47:27 +0000 | [diff] [blame] | 235 | int recovery; /* run in recovery mode */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 236 | }; |
| 237 | |
| 238 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 239 | * xmlSAXLocator: |
| 240 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 241 | * A SAX Locator. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 242 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 243 | struct _xmlSAXLocator { |
| 244 | const xmlChar *(*getPublicId)(void *ctx); |
| 245 | const xmlChar *(*getSystemId)(void *ctx); |
| 246 | int (*getLineNumber)(void *ctx); |
| 247 | int (*getColumnNumber)(void *ctx); |
| 248 | }; |
| 249 | |
| 250 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 251 | * xmlSAXHandler: |
| 252 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 253 | * 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] | 254 | * of the input generate data or structure informations. |
| 255 | */ |
| 256 | |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 257 | /** |
| 258 | * resolveEntitySAXFunc: |
| 259 | * @ctx: the user data (XML parser context) |
| 260 | * @publicId: The public ID of the entity |
| 261 | * @systemId: The system ID of the entity |
| 262 | * |
| 263 | * Callback: |
| 264 | * The entity loader, to control the loading of external entities, |
| 265 | * the application can either: |
| 266 | * - override this resolveEntity() callback in the SAX block |
| 267 | * - or better use the xmlSetExternalEntityLoader() function to |
| 268 | * set up it's own entity resolution routine |
| 269 | * |
| 270 | * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour. |
| 271 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 272 | typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 273 | const xmlChar *publicId, |
| 274 | const xmlChar *systemId); |
| 275 | /** |
| 276 | * internalSubsetSAXFunc: |
| 277 | * @ctx: the user data (XML parser context) |
| 278 | * @name: the root element name |
| 279 | * @ExternalID: the external ID |
| 280 | * @SystemID: the SYSTEM ID (e.g. filename or URL) |
| 281 | * |
| 282 | * Callback on internal subset declaration. |
| 283 | */ |
| 284 | typedef void (*internalSubsetSAXFunc) (void *ctx, |
| 285 | const xmlChar *name, |
| 286 | const xmlChar *ExternalID, |
| 287 | const xmlChar *SystemID); |
| 288 | /** |
| 289 | * externalSubsetSAXFunc: |
| 290 | * @ctx: the user data (XML parser context) |
| 291 | * @name: the root element name |
| 292 | * @ExternalID: the external ID |
| 293 | * @SystemID: the SYSTEM ID (e.g. filename or URL) |
| 294 | * |
| 295 | * Callback on external subset declaration. |
| 296 | */ |
| 297 | typedef void (*externalSubsetSAXFunc) (void *ctx, |
| 298 | const xmlChar *name, |
| 299 | const xmlChar *ExternalID, |
| 300 | const xmlChar *SystemID); |
| 301 | /** |
| 302 | * getEntitySAXFunc: |
| 303 | * @ctx: the user data (XML parser context) |
| 304 | * @name: The entity name |
| 305 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 306 | * Get an entity by name. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 307 | * |
| 308 | * Returns the xmlEntityPtr if found. |
| 309 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 310 | typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 311 | const xmlChar *name); |
| 312 | /** |
| 313 | * getParameterEntitySAXFunc: |
| 314 | * @ctx: the user data (XML parser context) |
| 315 | * @name: The entity name |
| 316 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 317 | * Get a parameter entity by name. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 318 | * |
| 319 | * Returns the xmlEntityPtr if found. |
| 320 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 321 | typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 322 | const xmlChar *name); |
| 323 | /** |
| 324 | * entityDeclSAXFunc: |
| 325 | * @ctx: the user data (XML parser context) |
| 326 | * @name: the entity name |
| 327 | * @type: the entity type |
| 328 | * @publicId: The public ID of the entity |
| 329 | * @systemId: The system ID of the entity |
| 330 | * @content: the entity value (without processing). |
| 331 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 332 | * An entity definition has been parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 333 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 334 | typedef void (*entityDeclSAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 335 | const xmlChar *name, |
| 336 | int type, |
| 337 | const xmlChar *publicId, |
| 338 | const xmlChar *systemId, |
| 339 | xmlChar *content); |
| 340 | /** |
| 341 | * notationDeclSAXFunc: |
| 342 | * @ctx: the user data (XML parser context) |
| 343 | * @name: The name of the notation |
| 344 | * @publicId: The public ID of the entity |
| 345 | * @systemId: The system ID of the entity |
| 346 | * |
| 347 | * What to do when a notation declaration has been parsed. |
| 348 | */ |
| 349 | typedef void (*notationDeclSAXFunc)(void *ctx, |
| 350 | const xmlChar *name, |
| 351 | const xmlChar *publicId, |
| 352 | const xmlChar *systemId); |
| 353 | /** |
| 354 | * attributeDeclSAXFunc: |
| 355 | * @ctx: the user data (XML parser context) |
| 356 | * @elem: the name of the element |
| 357 | * @fullname: the attribute name |
| 358 | * @type: the attribute type |
| 359 | * @def: the type of default value |
| 360 | * @defaultValue: the attribute default value |
| 361 | * @tree: the tree of enumerated value set |
| 362 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 363 | * An attribute definition has been parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 364 | */ |
| 365 | typedef void (*attributeDeclSAXFunc)(void *ctx, |
| 366 | const xmlChar *elem, |
| 367 | const xmlChar *fullname, |
| 368 | int type, |
| 369 | int def, |
| 370 | const xmlChar *defaultValue, |
| 371 | xmlEnumerationPtr tree); |
| 372 | /** |
| 373 | * elementDeclSAXFunc: |
| 374 | * @ctx: the user data (XML parser context) |
| 375 | * @name: the element name |
| 376 | * @type: the element type |
| 377 | * @content: the element value tree |
| 378 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 379 | * An element definition has been parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 380 | */ |
| 381 | typedef void (*elementDeclSAXFunc)(void *ctx, |
| 382 | const xmlChar *name, |
| 383 | int type, |
| 384 | xmlElementContentPtr content); |
| 385 | /** |
| 386 | * unparsedEntityDeclSAXFunc: |
| 387 | * @ctx: the user data (XML parser context) |
| 388 | * @name: The name of the entity |
| 389 | * @publicId: The public ID of the entity |
| 390 | * @systemId: The system ID of the entity |
| 391 | * @notationName: the name of the notation |
| 392 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 393 | * What to do when an unparsed entity declaration is parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 394 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 395 | typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 396 | const xmlChar *name, |
| 397 | const xmlChar *publicId, |
| 398 | const xmlChar *systemId, |
| 399 | const xmlChar *notationName); |
| 400 | /** |
| 401 | * setDocumentLocatorSAXFunc: |
| 402 | * @ctx: the user data (XML parser context) |
| 403 | * @loc: A SAX Locator |
| 404 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 405 | * Receive the document locator at startup, actually xmlDefaultSAXLocator. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 406 | * Everything is available on the context, so this is useless in our case. |
| 407 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 408 | typedef void (*setDocumentLocatorSAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 409 | xmlSAXLocatorPtr loc); |
| 410 | /** |
| 411 | * startDocumentSAXFunc: |
| 412 | * @ctx: the user data (XML parser context) |
| 413 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 414 | * Called when the document start being processed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 415 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 416 | typedef void (*startDocumentSAXFunc) (void *ctx); |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 417 | /** |
| 418 | * endDocumentSAXFunc: |
| 419 | * @ctx: the user data (XML parser context) |
| 420 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 421 | * Called when the document end has been detected. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 422 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 423 | typedef void (*endDocumentSAXFunc) (void *ctx); |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 424 | /** |
| 425 | * startElementSAXFunc: |
| 426 | * @ctx: the user data (XML parser context) |
| 427 | * @name: The element name, including namespace prefix |
| 428 | * @atts: An array of name/value attributes pairs, NULL terminated |
| 429 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 430 | * Called when an opening tag has been processed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 431 | */ |
| 432 | typedef void (*startElementSAXFunc) (void *ctx, |
| 433 | const xmlChar *name, |
| 434 | const xmlChar **atts); |
| 435 | /** |
| 436 | * endElementSAXFunc: |
| 437 | * @ctx: the user data (XML parser context) |
| 438 | * @name: The element name |
| 439 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 440 | * Called when the end of an element has been detected. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 441 | */ |
| 442 | typedef void (*endElementSAXFunc) (void *ctx, |
| 443 | const xmlChar *name); |
| 444 | /** |
| 445 | * attributeSAXFunc: |
| 446 | * @ctx: the user data (XML parser context) |
| 447 | * @name: The attribute name, including namespace prefix |
| 448 | * @value: The attribute value |
| 449 | * |
| 450 | * Handle an attribute that has been read by the parser. |
| 451 | * The default handling is to convert the attribute into an |
| 452 | * DOM subtree and past it in a new xmlAttr element added to |
| 453 | * the element. |
| 454 | */ |
| 455 | typedef void (*attributeSAXFunc) (void *ctx, |
| 456 | const xmlChar *name, |
| 457 | const xmlChar *value); |
| 458 | /** |
| 459 | * referenceSAXFunc: |
| 460 | * @ctx: the user data (XML parser context) |
| 461 | * @name: The entity name |
| 462 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 463 | * Called when an entity reference is detected. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 464 | */ |
| 465 | typedef void (*referenceSAXFunc) (void *ctx, |
| 466 | const xmlChar *name); |
| 467 | /** |
| 468 | * charactersSAXFunc: |
| 469 | * @ctx: the user data (XML parser context) |
| 470 | * @ch: a xmlChar string |
| 471 | * @len: the number of xmlChar |
| 472 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 473 | * Receiving some chars from the parser. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 474 | */ |
| 475 | typedef void (*charactersSAXFunc) (void *ctx, |
| 476 | const xmlChar *ch, |
| 477 | int len); |
| 478 | /** |
| 479 | * ignorableWhitespaceSAXFunc: |
| 480 | * @ctx: the user data (XML parser context) |
| 481 | * @ch: a xmlChar string |
| 482 | * @len: the number of xmlChar |
| 483 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 484 | * Receiving some ignorable whitespaces from the parser. |
| 485 | * UNUSED: by default the DOM building will use characters. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 486 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 487 | typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 488 | const xmlChar *ch, |
| 489 | int len); |
| 490 | /** |
| 491 | * processingInstructionSAXFunc: |
| 492 | * @ctx: the user data (XML parser context) |
| 493 | * @target: the target name |
| 494 | * @data: the PI data's |
| 495 | * |
| 496 | * A processing instruction has been parsed. |
| 497 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 498 | typedef void (*processingInstructionSAXFunc) (void *ctx, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 499 | const xmlChar *target, |
| 500 | const xmlChar *data); |
| 501 | /** |
| 502 | * commentSAXFunc: |
| 503 | * @ctx: the user data (XML parser context) |
| 504 | * @value: the comment content |
| 505 | * |
| 506 | * A comment has been parsed. |
| 507 | */ |
| 508 | typedef void (*commentSAXFunc) (void *ctx, |
| 509 | const xmlChar *value); |
| 510 | /** |
| 511 | * cdataBlockSAXFunc: |
| 512 | * @ctx: the user data (XML parser context) |
| 513 | * @value: The pcdata content |
| 514 | * @len: the block length |
| 515 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 516 | * Called when a pcdata block has been parsed. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 517 | */ |
| 518 | typedef void (*cdataBlockSAXFunc) ( |
| 519 | void *ctx, |
| 520 | const xmlChar *value, |
| 521 | int len); |
| 522 | /** |
| 523 | * warningSAXFunc: |
| 524 | * @ctx: an XML parser context |
| 525 | * @msg: the message to display/transmit |
| 526 | * @...: extra parameters for the message display |
| 527 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 528 | * Display and format a warning messages, callback. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 529 | */ |
| 530 | typedef void (*warningSAXFunc) (void *ctx, |
| 531 | const char *msg, ...); |
| 532 | /** |
| 533 | * errorSAXFunc: |
| 534 | * @ctx: an XML parser context |
| 535 | * @msg: the message to display/transmit |
| 536 | * @...: extra parameters for the message display |
| 537 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 538 | * Display and format an error messages, callback. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 539 | */ |
| 540 | typedef void (*errorSAXFunc) (void *ctx, |
| 541 | const char *msg, ...); |
| 542 | /** |
| 543 | * fatalErrorSAXFunc: |
| 544 | * @ctx: an XML parser context |
| 545 | * @msg: the message to display/transmit |
| 546 | * @...: extra parameters for the message display |
| 547 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 548 | * Display and format fatal error messages, callback. |
Daniel Veillard | 0821b15 | 2002-11-12 20:57:47 +0000 | [diff] [blame] | 549 | * Note: so far fatalError() SAX callbacks are not used, error() |
| 550 | * get all the callbacks for errors. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 551 | */ |
| 552 | typedef void (*fatalErrorSAXFunc) (void *ctx, |
| 553 | const char *msg, ...); |
| 554 | /** |
| 555 | * isStandaloneSAXFunc: |
| 556 | * @ctx: the user data (XML parser context) |
| 557 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 558 | * Is this document tagged standalone? |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 559 | * |
| 560 | * Returns 1 if true |
| 561 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 562 | typedef int (*isStandaloneSAXFunc) (void *ctx); |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 563 | /** |
| 564 | * hasInternalSubsetSAXFunc: |
| 565 | * @ctx: the user data (XML parser context) |
| 566 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 567 | * Does this document has an internal subset. |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 568 | * |
| 569 | * Returns 1 if true |
| 570 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 571 | typedef int (*hasInternalSubsetSAXFunc) (void *ctx); |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 572 | /** |
| 573 | * hasExternalSubsetSAXFunc: |
| 574 | * @ctx: the user data (XML parser context) |
| 575 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 576 | * Does this document has an external subset? |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 577 | * |
| 578 | * Returns 1 if true |
| 579 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 580 | typedef int (*hasExternalSubsetSAXFunc) (void *ctx); |
| 581 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 582 | struct _xmlSAXHandler { |
| 583 | internalSubsetSAXFunc internalSubset; |
| 584 | isStandaloneSAXFunc isStandalone; |
| 585 | hasInternalSubsetSAXFunc hasInternalSubset; |
| 586 | hasExternalSubsetSAXFunc hasExternalSubset; |
| 587 | resolveEntitySAXFunc resolveEntity; |
| 588 | getEntitySAXFunc getEntity; |
| 589 | entityDeclSAXFunc entityDecl; |
| 590 | notationDeclSAXFunc notationDecl; |
| 591 | attributeDeclSAXFunc attributeDecl; |
| 592 | elementDeclSAXFunc elementDecl; |
| 593 | unparsedEntityDeclSAXFunc unparsedEntityDecl; |
| 594 | setDocumentLocatorSAXFunc setDocumentLocator; |
| 595 | startDocumentSAXFunc startDocument; |
| 596 | endDocumentSAXFunc endDocument; |
| 597 | startElementSAXFunc startElement; |
| 598 | endElementSAXFunc endElement; |
| 599 | referenceSAXFunc reference; |
| 600 | charactersSAXFunc characters; |
| 601 | ignorableWhitespaceSAXFunc ignorableWhitespace; |
| 602 | processingInstructionSAXFunc processingInstruction; |
| 603 | commentSAXFunc comment; |
| 604 | warningSAXFunc warning; |
| 605 | errorSAXFunc error; |
Daniel Veillard | 0821b15 | 2002-11-12 20:57:47 +0000 | [diff] [blame] | 606 | fatalErrorSAXFunc fatalError; /* unused error() get all the errors */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 607 | getParameterEntitySAXFunc getParameterEntity; |
| 608 | cdataBlockSAXFunc cdataBlock; |
| 609 | externalSubsetSAXFunc externalSubset; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 610 | int initialized; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 611 | }; |
| 612 | |
| 613 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 614 | * xmlExternalEntityLoader: |
| 615 | * @URL: The System ID of the resource requested |
| 616 | * @ID: The Public ID of the resource requested |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 617 | * @context: the XML parser context |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 618 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 619 | * External entity loaders types. |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame] | 620 | * |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 621 | * Returns the entity input parser. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 622 | */ |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 623 | typedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL, |
| 624 | const char *ID, |
| 625 | xmlParserCtxtPtr context); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 626 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 627 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 628 | * Global variables: just the default SAX interface tables and XML |
| 629 | * version infos. |
| 630 | */ |
Daniel Veillard | 0ba5923 | 2002-02-10 13:20:39 +0000 | [diff] [blame] | 631 | #if 0 |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 632 | LIBXML_DLL_IMPORT extern const char *xmlParserVersion; |
Daniel Veillard | 0ba5923 | 2002-02-10 13:20:39 +0000 | [diff] [blame] | 633 | #endif |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 634 | |
Daniel Veillard | 0ba5923 | 2002-02-10 13:20:39 +0000 | [diff] [blame] | 635 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 636 | LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator; |
| 637 | LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler; |
| 638 | LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler; |
Daniel Veillard | eae522a | 2001-04-23 13:41:34 +0000 | [diff] [blame] | 639 | LIBXML_DLL_IMPORT extern xmlSAXHandler docbDefaultSAXHandler; |
Daniel Veillard | 0ba5923 | 2002-02-10 13:20:39 +0000 | [diff] [blame] | 640 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 641 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 642 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 643 | * Entity substitution default behavior. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 644 | */ |
| 645 | |
Daniel Veillard | 0ba5923 | 2002-02-10 13:20:39 +0000 | [diff] [blame] | 646 | #if 0 |
| 647 | LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 648 | LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue; |
Daniel Veillard | 0ba5923 | 2002-02-10 13:20:39 +0000 | [diff] [blame] | 649 | #endif |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 650 | |
Daniel Veillard | 6c4ffaf | 2002-02-11 08:54:05 +0000 | [diff] [blame] | 651 | #ifdef __cplusplus |
| 652 | } |
| 653 | #endif |
| 654 | #include <libxml/encoding.h> |
| 655 | #include <libxml/xmlIO.h> |
| 656 | #include <libxml/globals.h> |
| 657 | #ifdef __cplusplus |
| 658 | extern "C" { |
| 659 | #endif |
| 660 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 661 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 662 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 663 | * Init/Cleanup |
| 664 | */ |
| 665 | void xmlInitParser (void); |
| 666 | void xmlCleanupParser (void); |
| 667 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 668 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 669 | * Input functions |
| 670 | */ |
| 671 | int xmlParserInputRead (xmlParserInputPtr in, |
| 672 | int len); |
| 673 | int xmlParserInputGrow (xmlParserInputPtr in, |
| 674 | int len); |
| 675 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 676 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 677 | * xmlChar handling |
| 678 | */ |
| 679 | xmlChar * xmlStrdup (const xmlChar *cur); |
| 680 | xmlChar * xmlStrndup (const xmlChar *cur, |
| 681 | int len); |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 682 | xmlChar * xmlCharStrndup (const char *cur, |
| 683 | int len); |
| 684 | xmlChar * xmlCharStrdup (const char *cur); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 685 | xmlChar * xmlStrsub (const xmlChar *str, |
| 686 | int start, |
| 687 | int len); |
| 688 | const xmlChar * xmlStrchr (const xmlChar *str, |
| 689 | xmlChar val); |
| 690 | const xmlChar * xmlStrstr (const xmlChar *str, |
Daniel Veillard | 7704473 | 2001-06-29 21:31:07 +0000 | [diff] [blame] | 691 | const xmlChar *val); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 692 | const xmlChar * xmlStrcasestr (const xmlChar *str, |
| 693 | xmlChar *val); |
| 694 | int xmlStrcmp (const xmlChar *str1, |
| 695 | const xmlChar *str2); |
| 696 | int xmlStrncmp (const xmlChar *str1, |
| 697 | const xmlChar *str2, |
| 698 | int len); |
| 699 | int xmlStrcasecmp (const xmlChar *str1, |
| 700 | const xmlChar *str2); |
| 701 | int xmlStrncasecmp (const xmlChar *str1, |
| 702 | const xmlChar *str2, |
| 703 | int len); |
| 704 | int xmlStrEqual (const xmlChar *str1, |
| 705 | const xmlChar *str2); |
| 706 | int xmlStrlen (const xmlChar *str); |
| 707 | xmlChar * xmlStrcat (xmlChar *cur, |
| 708 | const xmlChar *add); |
| 709 | xmlChar * xmlStrncat (xmlChar *cur, |
| 710 | const xmlChar *add, |
| 711 | int len); |
| 712 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 713 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 714 | * Basic parsing Interfaces |
| 715 | */ |
| 716 | xmlDocPtr xmlParseDoc (xmlChar *cur); |
Daniel Veillard | 50822cb | 2001-07-26 20:05:51 +0000 | [diff] [blame] | 717 | xmlDocPtr xmlParseMemory (const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 718 | int size); |
| 719 | xmlDocPtr xmlParseFile (const char *filename); |
| 720 | int xmlSubstituteEntitiesDefault(int val); |
| 721 | int xmlKeepBlanksDefault (int val); |
| 722 | void xmlStopParser (xmlParserCtxtPtr ctxt); |
| 723 | int xmlPedanticParserDefault(int val); |
Daniel Veillard | d9bad13 | 2001-07-23 19:39:43 +0000 | [diff] [blame] | 724 | int xmlLineNumbersDefault (int val); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 725 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 726 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 727 | * Recovery mode |
| 728 | */ |
| 729 | xmlDocPtr xmlRecoverDoc (xmlChar *cur); |
Daniel Veillard | 50822cb | 2001-07-26 20:05:51 +0000 | [diff] [blame] | 730 | xmlDocPtr xmlRecoverMemory (const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 731 | int size); |
| 732 | xmlDocPtr xmlRecoverFile (const char *filename); |
| 733 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 734 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 735 | * Less common routines and SAX interfaces |
| 736 | */ |
| 737 | int xmlParseDocument (xmlParserCtxtPtr ctxt); |
| 738 | int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); |
| 739 | xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax, |
| 740 | xmlChar *cur, |
| 741 | int recovery); |
| 742 | int xmlSAXUserParseFile (xmlSAXHandlerPtr sax, |
| 743 | void *user_data, |
| 744 | const char *filename); |
| 745 | int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, |
| 746 | void *user_data, |
Daniel Veillard | fd7ddca | 2001-05-16 10:57:35 +0000 | [diff] [blame] | 747 | const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 748 | int size); |
| 749 | xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax, |
Daniel Veillard | 50822cb | 2001-07-26 20:05:51 +0000 | [diff] [blame] | 750 | const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 751 | int size, |
| 752 | int recovery); |
Daniel Veillard | 8606bbb | 2002-11-12 12:36:52 +0000 | [diff] [blame] | 753 | xmlDocPtr xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax, |
| 754 | const char *buffer, |
| 755 | int size, |
| 756 | int recovery, |
| 757 | void *data); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 758 | xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax, |
| 759 | const char *filename, |
| 760 | int recovery); |
Daniel Veillard | a293c32 | 2001-10-02 13:54:14 +0000 | [diff] [blame] | 761 | xmlDocPtr xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, |
| 762 | const char *filename, |
| 763 | int recovery, |
| 764 | void *data); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 765 | xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax, |
| 766 | const char *filename); |
| 767 | xmlDocPtr xmlParseEntity (const char *filename); |
| 768 | xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID, |
| 769 | const xmlChar *SystemID); |
| 770 | xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax, |
| 771 | const xmlChar *ExternalID, |
| 772 | const xmlChar *SystemID); |
| 773 | xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax, |
| 774 | xmlParserInputBufferPtr input, |
| 775 | xmlCharEncoding enc); |
| 776 | int xmlParseBalancedChunkMemory(xmlDocPtr doc, |
| 777 | xmlSAXHandlerPtr sax, |
| 778 | void *user_data, |
| 779 | int depth, |
| 780 | const xmlChar *string, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 781 | xmlNodePtr *lst); |
Daniel Veillard | 58e44c9 | 2002-08-02 22:19:49 +0000 | [diff] [blame] | 782 | int xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, |
| 783 | xmlSAXHandlerPtr sax, |
| 784 | void *user_data, |
| 785 | int depth, |
| 786 | const xmlChar *string, |
| 787 | xmlNodePtr *lst, |
| 788 | int recover); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 789 | int xmlParseExternalEntity (xmlDocPtr doc, |
| 790 | xmlSAXHandlerPtr sax, |
| 791 | void *user_data, |
| 792 | int depth, |
| 793 | const xmlChar *URL, |
| 794 | const xmlChar *ID, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 795 | xmlNodePtr *lst); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 796 | int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, |
| 797 | const xmlChar *URL, |
| 798 | const xmlChar *ID, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 799 | xmlNodePtr *lst); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 800 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 801 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 802 | * Parser contexts handling. |
| 803 | */ |
| 804 | void xmlInitParserCtxt (xmlParserCtxtPtr ctxt); |
| 805 | void xmlClearParserCtxt (xmlParserCtxtPtr ctxt); |
| 806 | void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); |
| 807 | void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, |
| 808 | const xmlChar* buffer, |
Daniel Veillard | 963d2ae | 2002-01-20 22:08:18 +0000 | [diff] [blame] | 809 | const char *filename); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 810 | xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur); |
| 811 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 812 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 813 | * Reading/setting optional parsing features. |
| 814 | */ |
| 815 | |
| 816 | int xmlGetFeaturesList (int *len, |
| 817 | const char **result); |
| 818 | int xmlGetFeature (xmlParserCtxtPtr ctxt, |
| 819 | const char *name, |
| 820 | void *result); |
| 821 | int xmlSetFeature (xmlParserCtxtPtr ctxt, |
| 822 | const char *name, |
| 823 | void *value); |
| 824 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 825 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 826 | * Interfaces for the Push mode. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 827 | */ |
| 828 | xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, |
| 829 | void *user_data, |
| 830 | const char *chunk, |
| 831 | int size, |
| 832 | const char *filename); |
| 833 | int xmlParseChunk (xmlParserCtxtPtr ctxt, |
| 834 | const char *chunk, |
| 835 | int size, |
| 836 | int terminate); |
| 837 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 838 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 839 | * Special I/O mode. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 840 | */ |
| 841 | |
| 842 | xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, |
| 843 | void *user_data, |
| 844 | xmlInputReadCallback ioread, |
| 845 | xmlInputCloseCallback ioclose, |
| 846 | void *ioctx, |
| 847 | xmlCharEncoding enc); |
| 848 | |
| 849 | xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt, |
| 850 | xmlParserInputBufferPtr input, |
| 851 | xmlCharEncoding enc); |
| 852 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 853 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 854 | * Node infos. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 855 | */ |
| 856 | const xmlParserNodeInfo* |
Daniel Veillard | 963d2ae | 2002-01-20 22:08:18 +0000 | [diff] [blame] | 857 | xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt, |
| 858 | const xmlNodePtr node); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 859 | void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
| 860 | void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
Daniel Veillard | 963d2ae | 2002-01-20 22:08:18 +0000 | [diff] [blame] | 861 | unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq, |
| 862 | const xmlNodePtr node); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 863 | void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, |
Daniel Veillard | 963d2ae | 2002-01-20 22:08:18 +0000 | [diff] [blame] | 864 | const xmlParserNodeInfoPtr info); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 865 | |
| 866 | /* |
Daniel Veillard | 61f2617 | 2002-03-12 18:46:39 +0000 | [diff] [blame] | 867 | * External entities handling actually implemented in xmlIO. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 868 | */ |
| 869 | |
| 870 | void xmlSetExternalEntityLoader(xmlExternalEntityLoader f); |
| 871 | xmlExternalEntityLoader |
| 872 | xmlGetExternalEntityLoader(void); |
| 873 | xmlParserInputPtr |
| 874 | xmlLoadExternalEntity (const char *URL, |
| 875 | const char *ID, |
Daniel Veillard | 9d06d30 | 2002-01-22 18:15:52 +0000 | [diff] [blame] | 876 | xmlParserCtxtPtr ctxt); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 877 | |
| 878 | #ifdef __cplusplus |
| 879 | } |
| 880 | #endif |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 881 | #endif /* __XML_PARSER_H__ */ |
| 882 | |