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