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