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