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