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> |
Daniel Veillard | 8bdb91d | 2001-10-31 17:52:43 +0000 | [diff] [blame] | 15 | #include <libxml/encoding.h> |
| 16 | #include <libxml/xmlIO.h> |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 17 | |
| 18 | #ifdef __cplusplus |
| 19 | extern "C" { |
| 20 | #endif |
| 21 | |
Daniel Veillard | 5e2dace | 2001-07-18 19:30:27 +0000 | [diff] [blame] | 22 | /** |
| 23 | * XML_DEFAULT_VERSION: |
| 24 | * |
| 25 | * The default version of XML used: 1.0 |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 26 | */ |
| 27 | #define XML_DEFAULT_VERSION "1.0" |
| 28 | |
| 29 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 30 | * xmlParserInput: |
| 31 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 32 | * an xmlParserInput is an input flow for the XML processor. |
| 33 | * Each entity parsed is associated an xmlParserInput (except the |
| 34 | * few predefined ones). This is the case both for internal entities |
| 35 | * - in which case the flow is already completely in memory - or |
| 36 | * external entities - in which case we use the buf structure for |
| 37 | * progressive reading and I18N conversions to the internal UTF-8 format. |
| 38 | */ |
| 39 | |
| 40 | typedef void (* xmlParserInputDeallocate)(xmlChar *); |
Daniel Veillard | 5e2dace | 2001-07-18 19:30:27 +0000 | [diff] [blame] | 41 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 42 | struct _xmlParserInput { |
| 43 | /* Input buffer */ |
| 44 | xmlParserInputBufferPtr buf; /* UTF-8 encoded buffer */ |
| 45 | |
| 46 | const char *filename; /* The file analyzed, if any */ |
Daniel Veillard | 60087f3 | 2001-10-10 09:45:09 +0000 | [diff] [blame] | 47 | const char *directory; /* the directory/base of the file */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 48 | const xmlChar *base; /* Base of the array to parse */ |
| 49 | const xmlChar *cur; /* Current char being parsed */ |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame^] | 50 | const xmlChar *end; /* end of the array to parse */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 51 | int length; /* length if known */ |
| 52 | int line; /* Current line */ |
| 53 | int col; /* Current column */ |
| 54 | int consumed; /* How many xmlChars already consumed */ |
| 55 | xmlParserInputDeallocate free; /* function to deallocate the base */ |
| 56 | const xmlChar *encoding; /* the encoding string for entity */ |
| 57 | const xmlChar *version; /* the version string for entity */ |
| 58 | int standalone; /* Was that entity marked standalone */ |
| 59 | }; |
| 60 | |
| 61 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 62 | * xmlParserNodeInfo: |
| 63 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 64 | * the parser can be asked to collect Node informations, i.e. at what |
| 65 | * place in the file they were detected. |
| 66 | * NOTE: This is off by default and not very well tested. |
| 67 | */ |
| 68 | typedef struct _xmlParserNodeInfo xmlParserNodeInfo; |
| 69 | typedef xmlParserNodeInfo *xmlParserNodeInfoPtr; |
| 70 | |
| 71 | struct _xmlParserNodeInfo { |
| 72 | const struct _xmlNode* node; |
| 73 | /* Position & line # that text that created the node begins & ends on */ |
| 74 | unsigned long begin_pos; |
| 75 | unsigned long begin_line; |
| 76 | unsigned long end_pos; |
| 77 | unsigned long end_line; |
| 78 | }; |
| 79 | |
| 80 | typedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq; |
| 81 | typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr; |
| 82 | struct _xmlParserNodeInfoSeq { |
| 83 | unsigned long maximum; |
| 84 | unsigned long length; |
| 85 | xmlParserNodeInfo* buffer; |
| 86 | }; |
| 87 | |
| 88 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 89 | * xmlParserInputState: |
| 90 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 91 | * The parser is now working also as a state based parser |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame^] | 92 | * The recursive one use the state info for entities processing |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 93 | */ |
| 94 | typedef enum { |
| 95 | XML_PARSER_EOF = -1, /* nothing is to be parsed */ |
| 96 | XML_PARSER_START = 0, /* nothing has been parsed */ |
| 97 | XML_PARSER_MISC, /* Misc* before int subset */ |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame^] | 98 | XML_PARSER_PI, /* Within a processing instruction */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 99 | XML_PARSER_DTD, /* within some DTD content */ |
| 100 | XML_PARSER_PROLOG, /* Misc* after internal subset */ |
| 101 | XML_PARSER_COMMENT, /* within a comment */ |
| 102 | XML_PARSER_START_TAG, /* within a start tag */ |
| 103 | XML_PARSER_CONTENT, /* within the content */ |
| 104 | XML_PARSER_CDATA_SECTION, /* within a CDATA section */ |
| 105 | XML_PARSER_END_TAG, /* within a closing tag */ |
| 106 | XML_PARSER_ENTITY_DECL, /* within an entity declaration */ |
| 107 | XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */ |
| 108 | XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */ |
| 109 | XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */ |
| 110 | XML_PARSER_EPILOG, /* the Misc* after the last end tag */ |
| 111 | XML_PARSER_IGNORE /* within an IGNORED section */ |
| 112 | } xmlParserInputState; |
| 113 | |
| 114 | /** |
Daniel Veillard | d16df9f | 2001-05-23 13:44:21 +0000 | [diff] [blame] | 115 | * XML_DETECT_IDS: |
| 116 | * |
| 117 | * Bit in the loadsubset context field to tell to do ID/REFs lookups |
| 118 | * Use it to initialize xmlLoadExtDtdDefaultValue |
| 119 | */ |
| 120 | #define XML_DETECT_IDS 2 |
| 121 | |
| 122 | /** |
| 123 | * XML_COMPLETE_ATTRS: |
| 124 | * |
| 125 | * Bit in the loadsubset context field to tell to do complete the |
| 126 | * elements attributes lists with the ones defaulted from the DTDs |
| 127 | * Use it to initialize xmlLoadExtDtdDefaultValue |
| 128 | */ |
| 129 | #define XML_COMPLETE_ATTRS 4 |
| 130 | |
| 131 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 132 | * xmlParserCtxt: |
| 133 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 134 | * The parser context. |
| 135 | * NOTE This doesn't completely defines the parser state, the (current ?) |
| 136 | * design of the parser uses recursive function calls since this allow |
| 137 | * and easy mapping from the production rules of the specification |
| 138 | * to the actual code. The drawback is that the actual function call |
| 139 | * also reflect the parser state. However most of the parsing routines |
| 140 | * takes as the only argument the parser context pointer, so migrating |
| 141 | * to a state based parser for progressive parsing shouldn't be too hard. |
| 142 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 143 | struct _xmlParserCtxt { |
| 144 | struct _xmlSAXHandler *sax; /* The SAX handler */ |
| 145 | void *userData; /* For SAX interface only, used by DOM build */ |
| 146 | xmlDocPtr myDoc; /* the document being built */ |
| 147 | int wellFormed; /* is the document well formed */ |
| 148 | int replaceEntities; /* shall we replace entities ? */ |
| 149 | const xmlChar *version; /* the XML version string */ |
| 150 | const xmlChar *encoding; /* the declared encoding, if any */ |
| 151 | int standalone; /* standalone document */ |
| 152 | int html; /* an HTML(1)/Docbook(2) document */ |
| 153 | |
| 154 | /* Input stream stack */ |
| 155 | xmlParserInputPtr input; /* Current input stream */ |
| 156 | int inputNr; /* Number of current input streams */ |
| 157 | int inputMax; /* Max number of input streams */ |
| 158 | xmlParserInputPtr *inputTab; /* stack of inputs */ |
| 159 | |
| 160 | /* Node analysis stack only used for DOM building */ |
| 161 | xmlNodePtr node; /* Current parsed Node */ |
| 162 | int nodeNr; /* Depth of the parsing stack */ |
| 163 | int nodeMax; /* Max depth of the parsing stack */ |
| 164 | xmlNodePtr *nodeTab; /* array of nodes */ |
| 165 | |
| 166 | int record_info; /* Whether node info should be kept */ |
| 167 | xmlParserNodeInfoSeq node_seq; /* info about each node parsed */ |
| 168 | |
| 169 | int errNo; /* error code */ |
| 170 | |
| 171 | int hasExternalSubset; /* reference and external subset */ |
| 172 | int hasPErefs; /* the internal subset has PE refs */ |
| 173 | int external; /* are we parsing an external entity */ |
| 174 | |
| 175 | int valid; /* is the document valid */ |
| 176 | int validate; /* shall we try to validate ? */ |
| 177 | xmlValidCtxt vctxt; /* The validity context */ |
| 178 | |
| 179 | xmlParserInputState instate; /* current type of input */ |
| 180 | int token; /* next char look-ahead */ |
| 181 | |
| 182 | char *directory; /* the data directory */ |
| 183 | |
| 184 | /* Node name stack */ |
| 185 | xmlChar *name; /* Current parsed Node */ |
| 186 | int nameNr; /* Depth of the parsing stack */ |
| 187 | int nameMax; /* Max depth of the parsing stack */ |
| 188 | xmlChar * *nameTab; /* array of nodes */ |
| 189 | |
| 190 | long nbChars; /* number of xmlChar processed */ |
| 191 | long checkIndex; /* used by progressive parsing lookup */ |
| 192 | int keepBlanks; /* ugly but ... */ |
| 193 | int disableSAX; /* SAX callbacks are disabled */ |
| 194 | int inSubset; /* Parsing is in int 1/ext 2 subset */ |
| 195 | xmlChar * intSubName; /* name of subset */ |
| 196 | xmlChar * extSubURI; /* URI of external subset */ |
| 197 | xmlChar * extSubSystem; /* SYSTEM ID of external subset */ |
| 198 | |
| 199 | /* xml:space values */ |
| 200 | int * space; /* Should the parser preserve spaces */ |
| 201 | int spaceNr; /* Depth of the parsing stack */ |
| 202 | int spaceMax; /* Max depth of the parsing stack */ |
| 203 | int * spaceTab; /* array of space infos */ |
| 204 | |
| 205 | int depth; /* to prevent entity substitution loops */ |
| 206 | xmlParserInputPtr entity; /* used to check entities boundaries */ |
| 207 | int charset; /* encoding of the in-memory content |
| 208 | actually an xmlCharEncoding */ |
| 209 | int nodelen; /* Those two fields are there to */ |
| 210 | int nodemem; /* Speed up large node parsing */ |
| 211 | int pedantic; /* signal pedantic warnings */ |
| 212 | void *_private; /* For user data, libxml won't touch it */ |
| 213 | |
| 214 | int loadsubset; /* should the external subset be loaded */ |
Daniel Veillard | d9bad13 | 2001-07-23 19:39:43 +0000 | [diff] [blame] | 215 | int linenumbers; /* set line number in element content */ |
Daniel Veillard | 5d90b6c | 2001-08-22 14:29:45 +0000 | [diff] [blame] | 216 | void *catalogs; /* document's own catalog */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 217 | }; |
| 218 | |
| 219 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 220 | * xmlSAXLocator: |
| 221 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 222 | * a SAX Locator. |
| 223 | */ |
| 224 | typedef struct _xmlSAXLocator xmlSAXLocator; |
| 225 | typedef xmlSAXLocator *xmlSAXLocatorPtr; |
| 226 | struct _xmlSAXLocator { |
| 227 | const xmlChar *(*getPublicId)(void *ctx); |
| 228 | const xmlChar *(*getSystemId)(void *ctx); |
| 229 | int (*getLineNumber)(void *ctx); |
| 230 | int (*getColumnNumber)(void *ctx); |
| 231 | }; |
| 232 | |
| 233 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 234 | * xmlSAXHandler: |
| 235 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 236 | * a SAX handler is bunch of callbacks called by the parser when processing |
| 237 | * of the input generate data or structure informations. |
| 238 | */ |
| 239 | |
| 240 | typedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx, |
| 241 | const xmlChar *publicId, const xmlChar *systemId); |
| 242 | typedef void (*internalSubsetSAXFunc) (void *ctx, const xmlChar *name, |
| 243 | const xmlChar *ExternalID, const xmlChar *SystemID); |
| 244 | typedef void (*externalSubsetSAXFunc) (void *ctx, const xmlChar *name, |
| 245 | const xmlChar *ExternalID, const xmlChar *SystemID); |
| 246 | typedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx, |
| 247 | const xmlChar *name); |
| 248 | typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx, |
| 249 | const xmlChar *name); |
| 250 | typedef void (*entityDeclSAXFunc) (void *ctx, |
| 251 | const xmlChar *name, int type, const xmlChar *publicId, |
| 252 | const xmlChar *systemId, xmlChar *content); |
| 253 | typedef void (*notationDeclSAXFunc)(void *ctx, const xmlChar *name, |
| 254 | const xmlChar *publicId, const xmlChar *systemId); |
| 255 | typedef void (*attributeDeclSAXFunc)(void *ctx, const xmlChar *elem, |
| 256 | const xmlChar *name, int type, int def, |
| 257 | const xmlChar *defaultValue, xmlEnumerationPtr tree); |
| 258 | typedef void (*elementDeclSAXFunc)(void *ctx, const xmlChar *name, |
| 259 | int type, xmlElementContentPtr content); |
| 260 | typedef void (*unparsedEntityDeclSAXFunc)(void *ctx, |
| 261 | const xmlChar *name, const xmlChar *publicId, |
| 262 | const xmlChar *systemId, const xmlChar *notationName); |
| 263 | typedef void (*setDocumentLocatorSAXFunc) (void *ctx, |
| 264 | xmlSAXLocatorPtr loc); |
| 265 | typedef void (*startDocumentSAXFunc) (void *ctx); |
| 266 | typedef void (*endDocumentSAXFunc) (void *ctx); |
| 267 | typedef void (*startElementSAXFunc) (void *ctx, const xmlChar *name, |
| 268 | const xmlChar **atts); |
| 269 | typedef void (*endElementSAXFunc) (void *ctx, const xmlChar *name); |
| 270 | typedef void (*attributeSAXFunc) (void *ctx, const xmlChar *name, |
| 271 | const xmlChar *value); |
| 272 | typedef void (*referenceSAXFunc) (void *ctx, const xmlChar *name); |
| 273 | typedef void (*charactersSAXFunc) (void *ctx, const xmlChar *ch, |
| 274 | int len); |
| 275 | typedef void (*ignorableWhitespaceSAXFunc) (void *ctx, |
| 276 | const xmlChar *ch, int len); |
| 277 | typedef void (*processingInstructionSAXFunc) (void *ctx, |
| 278 | const xmlChar *target, const xmlChar *data); |
| 279 | typedef void (*commentSAXFunc) (void *ctx, const xmlChar *value); |
| 280 | typedef void (*cdataBlockSAXFunc) (void *ctx, const xmlChar *value, int len); |
| 281 | typedef void (*warningSAXFunc) (void *ctx, const char *msg, ...); |
| 282 | typedef void (*errorSAXFunc) (void *ctx, const char *msg, ...); |
| 283 | typedef void (*fatalErrorSAXFunc) (void *ctx, const char *msg, ...); |
| 284 | typedef int (*isStandaloneSAXFunc) (void *ctx); |
| 285 | typedef int (*hasInternalSubsetSAXFunc) (void *ctx); |
| 286 | typedef int (*hasExternalSubsetSAXFunc) (void *ctx); |
| 287 | |
| 288 | typedef struct _xmlSAXHandler xmlSAXHandler; |
| 289 | typedef xmlSAXHandler *xmlSAXHandlerPtr; |
| 290 | struct _xmlSAXHandler { |
| 291 | internalSubsetSAXFunc internalSubset; |
| 292 | isStandaloneSAXFunc isStandalone; |
| 293 | hasInternalSubsetSAXFunc hasInternalSubset; |
| 294 | hasExternalSubsetSAXFunc hasExternalSubset; |
| 295 | resolveEntitySAXFunc resolveEntity; |
| 296 | getEntitySAXFunc getEntity; |
| 297 | entityDeclSAXFunc entityDecl; |
| 298 | notationDeclSAXFunc notationDecl; |
| 299 | attributeDeclSAXFunc attributeDecl; |
| 300 | elementDeclSAXFunc elementDecl; |
| 301 | unparsedEntityDeclSAXFunc unparsedEntityDecl; |
| 302 | setDocumentLocatorSAXFunc setDocumentLocator; |
| 303 | startDocumentSAXFunc startDocument; |
| 304 | endDocumentSAXFunc endDocument; |
| 305 | startElementSAXFunc startElement; |
| 306 | endElementSAXFunc endElement; |
| 307 | referenceSAXFunc reference; |
| 308 | charactersSAXFunc characters; |
| 309 | ignorableWhitespaceSAXFunc ignorableWhitespace; |
| 310 | processingInstructionSAXFunc processingInstruction; |
| 311 | commentSAXFunc comment; |
| 312 | warningSAXFunc warning; |
| 313 | errorSAXFunc error; |
| 314 | fatalErrorSAXFunc fatalError; |
| 315 | getParameterEntitySAXFunc getParameterEntity; |
| 316 | cdataBlockSAXFunc cdataBlock; |
| 317 | externalSubsetSAXFunc externalSubset; |
Daniel Veillard | d046356 | 2001-10-13 09:15:48 +0000 | [diff] [blame] | 318 | int initialized; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 319 | }; |
| 320 | |
| 321 | /** |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 322 | * xmlExternalEntityLoader: |
| 323 | * @URL: The System ID of the resource requested |
| 324 | * @ID: The Public ID of the resource requested |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame^] | 325 | * @context: the XML parser context |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 326 | * |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 327 | * External entity loaders types |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame^] | 328 | * |
| 329 | * Returns the entity input parser |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 330 | */ |
| 331 | typedef xmlParserInputPtr (*xmlExternalEntityLoader)(const char *URL, |
| 332 | const char *ID, |
| 333 | xmlParserCtxtPtr context); |
| 334 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 335 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 336 | * Global variables: just the default SAX interface tables and XML |
| 337 | * version infos. |
| 338 | */ |
| 339 | LIBXML_DLL_IMPORT extern const char *xmlParserVersion; |
| 340 | |
| 341 | LIBXML_DLL_IMPORT extern xmlSAXLocator xmlDefaultSAXLocator; |
| 342 | LIBXML_DLL_IMPORT extern xmlSAXHandler xmlDefaultSAXHandler; |
| 343 | LIBXML_DLL_IMPORT extern xmlSAXHandler htmlDefaultSAXHandler; |
Daniel Veillard | eae522a | 2001-04-23 13:41:34 +0000 | [diff] [blame] | 344 | LIBXML_DLL_IMPORT extern xmlSAXHandler docbDefaultSAXHandler; |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 345 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 346 | /* |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame^] | 347 | * entity substitution default behavior. |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 348 | */ |
| 349 | |
| 350 | #ifdef VMS |
Daniel Veillard | 5e2dace | 2001-07-18 19:30:27 +0000 | [diff] [blame] | 351 | /** |
| 352 | * xmlSubstituteEntitiesDefaultValue: |
| 353 | * |
Daniel Veillard | cbaf399 | 2001-12-31 16:16:02 +0000 | [diff] [blame^] | 354 | * global variable controlling the entity substitution default behavior |
Daniel Veillard | 5e2dace | 2001-07-18 19:30:27 +0000 | [diff] [blame] | 355 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 356 | LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultVal; |
| 357 | #define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal |
| 358 | #else |
| 359 | LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue; |
| 360 | #endif |
| 361 | LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue; |
| 362 | |
| 363 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 364 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 365 | * Init/Cleanup |
| 366 | */ |
| 367 | void xmlInitParser (void); |
| 368 | void xmlCleanupParser (void); |
| 369 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 370 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 371 | * Input functions |
| 372 | */ |
| 373 | int xmlParserInputRead (xmlParserInputPtr in, |
| 374 | int len); |
| 375 | int xmlParserInputGrow (xmlParserInputPtr in, |
| 376 | int len); |
| 377 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 378 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 379 | * xmlChar handling |
| 380 | */ |
| 381 | xmlChar * xmlStrdup (const xmlChar *cur); |
| 382 | xmlChar * xmlStrndup (const xmlChar *cur, |
| 383 | int len); |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 384 | xmlChar * xmlCharStrndup (const char *cur, |
| 385 | int len); |
| 386 | xmlChar * xmlCharStrdup (const char *cur); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 387 | xmlChar * xmlStrsub (const xmlChar *str, |
| 388 | int start, |
| 389 | int len); |
| 390 | const xmlChar * xmlStrchr (const xmlChar *str, |
| 391 | xmlChar val); |
| 392 | const xmlChar * xmlStrstr (const xmlChar *str, |
Daniel Veillard | 7704473 | 2001-06-29 21:31:07 +0000 | [diff] [blame] | 393 | const xmlChar *val); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 394 | const xmlChar * xmlStrcasestr (const xmlChar *str, |
| 395 | xmlChar *val); |
| 396 | int xmlStrcmp (const xmlChar *str1, |
| 397 | const xmlChar *str2); |
| 398 | int xmlStrncmp (const xmlChar *str1, |
| 399 | const xmlChar *str2, |
| 400 | int len); |
| 401 | int xmlStrcasecmp (const xmlChar *str1, |
| 402 | const xmlChar *str2); |
| 403 | int xmlStrncasecmp (const xmlChar *str1, |
| 404 | const xmlChar *str2, |
| 405 | int len); |
| 406 | int xmlStrEqual (const xmlChar *str1, |
| 407 | const xmlChar *str2); |
| 408 | int xmlStrlen (const xmlChar *str); |
| 409 | xmlChar * xmlStrcat (xmlChar *cur, |
| 410 | const xmlChar *add); |
| 411 | xmlChar * xmlStrncat (xmlChar *cur, |
| 412 | const xmlChar *add, |
| 413 | int len); |
| 414 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 415 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 416 | * Basic parsing Interfaces |
| 417 | */ |
| 418 | xmlDocPtr xmlParseDoc (xmlChar *cur); |
Daniel Veillard | 50822cb | 2001-07-26 20:05:51 +0000 | [diff] [blame] | 419 | xmlDocPtr xmlParseMemory (const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 420 | int size); |
| 421 | xmlDocPtr xmlParseFile (const char *filename); |
| 422 | int xmlSubstituteEntitiesDefault(int val); |
| 423 | int xmlKeepBlanksDefault (int val); |
| 424 | void xmlStopParser (xmlParserCtxtPtr ctxt); |
| 425 | int xmlPedanticParserDefault(int val); |
Daniel Veillard | d9bad13 | 2001-07-23 19:39:43 +0000 | [diff] [blame] | 426 | int xmlLineNumbersDefault (int val); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 427 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 428 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 429 | * Recovery mode |
| 430 | */ |
| 431 | xmlDocPtr xmlRecoverDoc (xmlChar *cur); |
Daniel Veillard | 50822cb | 2001-07-26 20:05:51 +0000 | [diff] [blame] | 432 | xmlDocPtr xmlRecoverMemory (const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 433 | int size); |
| 434 | xmlDocPtr xmlRecoverFile (const char *filename); |
| 435 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 436 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 437 | * Less common routines and SAX interfaces |
| 438 | */ |
| 439 | int xmlParseDocument (xmlParserCtxtPtr ctxt); |
| 440 | int xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt); |
| 441 | xmlDocPtr xmlSAXParseDoc (xmlSAXHandlerPtr sax, |
| 442 | xmlChar *cur, |
| 443 | int recovery); |
| 444 | int xmlSAXUserParseFile (xmlSAXHandlerPtr sax, |
| 445 | void *user_data, |
| 446 | const char *filename); |
| 447 | int xmlSAXUserParseMemory (xmlSAXHandlerPtr sax, |
| 448 | void *user_data, |
Daniel Veillard | fd7ddca | 2001-05-16 10:57:35 +0000 | [diff] [blame] | 449 | const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 450 | int size); |
| 451 | xmlDocPtr xmlSAXParseMemory (xmlSAXHandlerPtr sax, |
Daniel Veillard | 50822cb | 2001-07-26 20:05:51 +0000 | [diff] [blame] | 452 | const char *buffer, |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 453 | int size, |
| 454 | int recovery); |
| 455 | xmlDocPtr xmlSAXParseFile (xmlSAXHandlerPtr sax, |
| 456 | const char *filename, |
| 457 | int recovery); |
Daniel Veillard | a293c32 | 2001-10-02 13:54:14 +0000 | [diff] [blame] | 458 | xmlDocPtr xmlSAXParseFileWithData (xmlSAXHandlerPtr sax, |
| 459 | const char *filename, |
| 460 | int recovery, |
| 461 | void *data); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 462 | xmlDocPtr xmlSAXParseEntity (xmlSAXHandlerPtr sax, |
| 463 | const char *filename); |
| 464 | xmlDocPtr xmlParseEntity (const char *filename); |
| 465 | xmlDtdPtr xmlParseDTD (const xmlChar *ExternalID, |
| 466 | const xmlChar *SystemID); |
| 467 | xmlDtdPtr xmlSAXParseDTD (xmlSAXHandlerPtr sax, |
| 468 | const xmlChar *ExternalID, |
| 469 | const xmlChar *SystemID); |
| 470 | xmlDtdPtr xmlIOParseDTD (xmlSAXHandlerPtr sax, |
| 471 | xmlParserInputBufferPtr input, |
| 472 | xmlCharEncoding enc); |
| 473 | int xmlParseBalancedChunkMemory(xmlDocPtr doc, |
| 474 | xmlSAXHandlerPtr sax, |
| 475 | void *user_data, |
| 476 | int depth, |
| 477 | const xmlChar *string, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 478 | xmlNodePtr *lst); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 479 | int xmlParseExternalEntity (xmlDocPtr doc, |
| 480 | xmlSAXHandlerPtr sax, |
| 481 | void *user_data, |
| 482 | int depth, |
| 483 | const xmlChar *URL, |
| 484 | const xmlChar *ID, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 485 | xmlNodePtr *lst); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 486 | int xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, |
| 487 | const xmlChar *URL, |
| 488 | const xmlChar *ID, |
Daniel Veillard | cda9692 | 2001-08-21 10:56:31 +0000 | [diff] [blame] | 489 | xmlNodePtr *lst); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 490 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 491 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 492 | * SAX initialization routines |
| 493 | */ |
| 494 | void xmlDefaultSAXHandlerInit(void); |
| 495 | void htmlDefaultSAXHandlerInit(void); |
| 496 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 497 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 498 | * Parser contexts handling. |
| 499 | */ |
| 500 | void xmlInitParserCtxt (xmlParserCtxtPtr ctxt); |
| 501 | void xmlClearParserCtxt (xmlParserCtxtPtr ctxt); |
| 502 | void xmlFreeParserCtxt (xmlParserCtxtPtr ctxt); |
| 503 | void xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt, |
| 504 | const xmlChar* buffer, |
| 505 | const char* filename); |
| 506 | xmlParserCtxtPtr xmlCreateDocParserCtxt (xmlChar *cur); |
| 507 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 508 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 509 | * Reading/setting optional parsing features. |
| 510 | */ |
| 511 | |
| 512 | int xmlGetFeaturesList (int *len, |
| 513 | const char **result); |
| 514 | int xmlGetFeature (xmlParserCtxtPtr ctxt, |
| 515 | const char *name, |
| 516 | void *result); |
| 517 | int xmlSetFeature (xmlParserCtxtPtr ctxt, |
| 518 | const char *name, |
| 519 | void *value); |
| 520 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 521 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 522 | * Interfaces for the Push mode |
| 523 | */ |
| 524 | xmlParserCtxtPtr xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, |
| 525 | void *user_data, |
| 526 | const char *chunk, |
| 527 | int size, |
| 528 | const char *filename); |
| 529 | int xmlParseChunk (xmlParserCtxtPtr ctxt, |
| 530 | const char *chunk, |
| 531 | int size, |
| 532 | int terminate); |
| 533 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 534 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 535 | * Special I/O mode |
| 536 | */ |
| 537 | |
| 538 | xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax, |
| 539 | void *user_data, |
| 540 | xmlInputReadCallback ioread, |
| 541 | xmlInputCloseCallback ioclose, |
| 542 | void *ioctx, |
| 543 | xmlCharEncoding enc); |
| 544 | |
| 545 | xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt, |
| 546 | xmlParserInputBufferPtr input, |
| 547 | xmlCharEncoding enc); |
| 548 | |
Daniel Veillard | f69bb4b | 2001-05-19 13:24:56 +0000 | [diff] [blame] | 549 | /* |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 550 | * Node infos |
| 551 | */ |
| 552 | const xmlParserNodeInfo* |
| 553 | xmlParserFindNodeInfo (const xmlParserCtxt* ctxt, |
| 554 | const xmlNode* node); |
| 555 | void xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
| 556 | void xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq); |
| 557 | unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq, |
| 558 | const xmlNode* node); |
| 559 | void xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt, |
| 560 | const xmlParserNodeInfo* info); |
| 561 | |
| 562 | /* |
| 563 | * External entities handling actually implemented in xmlIO |
| 564 | */ |
| 565 | |
| 566 | void xmlSetExternalEntityLoader(xmlExternalEntityLoader f); |
| 567 | xmlExternalEntityLoader |
| 568 | xmlGetExternalEntityLoader(void); |
| 569 | xmlParserInputPtr |
| 570 | xmlLoadExternalEntity (const char *URL, |
| 571 | const char *ID, |
| 572 | xmlParserCtxtPtr context); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 573 | |
| 574 | #ifdef __cplusplus |
| 575 | } |
| 576 | #endif |
| 577 | |
Daniel Veillard | 64a411c | 2001-10-15 12:32:07 +0000 | [diff] [blame] | 578 | #include <libxml/globals.h> |
| 579 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 580 | #endif /* __XML_PARSER_H__ */ |
| 581 | |