tagging release
[dasher.git] / Src / Common / Expat / lib / expat.h
blob46fb9f59754c09a25f994b20874c5f3b61de5ecf
1 /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
3 */
5 #ifndef XmlParse_INCLUDED
6 #define XmlParse_INCLUDED 1
8 #ifdef __VMS
9 /* 0 1 2 3 0 1 2 3
10 1234567890123456789012345678901 1234567890123456789012345678901 */
11 #define XML_SetProcessingInstructionHandler XML_SetProcessingInstrHandler
12 #define XML_SetUnparsedEntityDeclHandler XML_SetUnparsedEntDeclHandler
13 #define XML_SetStartNamespaceDeclHandler XML_SetStartNamespcDeclHandler
14 #define XML_SetExternalEntityRefHandlerArg XML_SetExternalEntRefHandlerArg
15 #endif
17 #include <stdlib.h>
19 #ifndef XMLPARSEAPI
20 #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
21 #ifdef _STATIC
22 #define XMLPARSEAPI(type) type __cdecl
23 #else
24 #define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl
25 #endif
26 #else
27 #define XMLPARSEAPI(type) type
28 #endif
29 #endif /* not defined XMLPARSEAPI */
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #ifdef XML_UNICODE_WCHAR_T
36 #define XML_UNICODE
37 #endif
39 struct XML_ParserStruct;
40 typedef struct XML_ParserStruct *XML_Parser;
42 #ifdef XML_UNICODE /* Information is UTF-16 encoded. */
43 #ifdef XML_UNICODE_WCHAR_T
44 typedef wchar_t XML_Char;
45 typedef wchar_t XML_LChar;
46 #else
47 typedef unsigned short XML_Char;
48 typedef char XML_LChar;
49 #endif /* XML_UNICODE_WCHAR_T */
50 #else /* Information is UTF-8 encoded. */
51 typedef char XML_Char;
52 typedef char XML_LChar;
53 #endif /* XML_UNICODE */
55 /* Should this be defined using stdbool.h when C99 is available? */
56 typedef unsigned char XML_Bool;
57 #define XML_TRUE ((XML_Bool) 1)
58 #define XML_FALSE ((XML_Bool) 0)
60 enum XML_Error {
61 XML_ERROR_NONE,
62 XML_ERROR_NO_MEMORY,
63 XML_ERROR_SYNTAX,
64 XML_ERROR_NO_ELEMENTS,
65 XML_ERROR_INVALID_TOKEN,
66 XML_ERROR_UNCLOSED_TOKEN,
67 XML_ERROR_PARTIAL_CHAR,
68 XML_ERROR_TAG_MISMATCH,
69 XML_ERROR_DUPLICATE_ATTRIBUTE,
70 XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
71 XML_ERROR_PARAM_ENTITY_REF,
72 XML_ERROR_UNDEFINED_ENTITY,
73 XML_ERROR_RECURSIVE_ENTITY_REF,
74 XML_ERROR_ASYNC_ENTITY,
75 XML_ERROR_BAD_CHAR_REF,
76 XML_ERROR_BINARY_ENTITY_REF,
77 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
78 XML_ERROR_MISPLACED_XML_PI,
79 XML_ERROR_UNKNOWN_ENCODING,
80 XML_ERROR_INCORRECT_ENCODING,
81 XML_ERROR_UNCLOSED_CDATA_SECTION,
82 XML_ERROR_EXTERNAL_ENTITY_HANDLING,
83 XML_ERROR_NOT_STANDALONE,
84 XML_ERROR_UNEXPECTED_STATE,
85 XML_ERROR_ENTITY_DECLARED_IN_PE,
86 XML_ERROR_FEATURE_REQUIRES_XML_DTD,
87 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
90 enum XML_Content_Type {
91 XML_CTYPE_EMPTY = 1,
92 XML_CTYPE_ANY,
93 XML_CTYPE_MIXED,
94 XML_CTYPE_NAME,
95 XML_CTYPE_CHOICE,
96 XML_CTYPE_SEQ
99 enum XML_Content_Quant {
100 XML_CQUANT_NONE,
101 XML_CQUANT_OPT,
102 XML_CQUANT_REP,
103 XML_CQUANT_PLUS
106 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
107 XML_CQUANT_NONE, and the other fields will be zero or NULL.
108 If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
109 numchildren will contain number of elements that may be mixed in
110 and children point to an array of XML_Content cells that will be
111 all of XML_CTYPE_NAME type with no quantification.
113 If type == XML_CTYPE_NAME, then the name points to the name, and
114 the numchildren field will be zero and children will be NULL. The
115 quant fields indicates any quantifiers placed on the name.
117 CHOICE and SEQ will have name NULL, the number of children in
118 numchildren and children will point, recursively, to an array
119 of XML_Content cells.
121 The EMPTY, ANY, and MIXED types will only occur at top level.
124 typedef struct XML_cp XML_Content;
126 struct XML_cp {
127 enum XML_Content_Type type;
128 enum XML_Content_Quant quant;
129 XML_Char *name;
130 unsigned int numchildren;
131 XML_Content *children;
134 /* This is called for an element declaration. See above for
135 description of the model argument. It's the caller's responsibility
136 to free model when finished with it.
138 typedef void (*XML_ElementDeclHandler) (void *userData, const XML_Char * name, XML_Content * model);
140 XMLPARSEAPI(void)
141 XML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl);
143 /* The Attlist declaration handler is called for *each* attribute. So
144 a single Attlist declaration with multiple attributes declared will
145 generate multiple calls to this handler. The "default" parameter
146 may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
147 keyword. The "isrequired" parameter will be true and the default
148 value will be NULL in the case of "#REQUIRED". If "isrequired" is
149 true and default is non-NULL, then this is a "#FIXED" default.
151 typedef void (*XML_AttlistDeclHandler) (void *userData, const XML_Char * elname, const XML_Char * attname, const XML_Char * att_type, const XML_Char * dflt, int isrequired);
153 XMLPARSEAPI(void)
154 XML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl);
156 /* The XML declaration handler is called for *both* XML declarations
157 and text declarations. The way to distinguish is that the version
158 parameter will be NULL for text declarations. The encoding
159 parameter may be NULL for XML declarations. The standalone
160 parameter will be -1, 0, or 1 indicating respectively that there
161 was no standalone parameter in the declaration, that it was given
162 as no, or that it was given as yes.
164 typedef void (*XML_XmlDeclHandler) (void *userData, const XML_Char * version, const XML_Char * encoding, int standalone);
166 XMLPARSEAPI(void)
167 XML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl);
169 typedef struct {
170 void *(*malloc_fcn) (size_t size);
171 void *(*realloc_fcn) (void *ptr, size_t size);
172 void (*free_fcn) (void *ptr);
173 } XML_Memory_Handling_Suite;
175 /* Constructs a new parser; encoding is the encoding specified by the
176 external protocol or NULL if there is none specified.
178 XMLPARSEAPI(XML_Parser)
179 XML_ParserCreate(const XML_Char * encoding);
181 /* Constructs a new parser and namespace processor. Element type
182 names and attribute names that belong to a namespace will be
183 expanded; unprefixed attribute names are never expanded; unprefixed
184 element type names are expanded only if there is a default
185 namespace. The expanded name is the concatenation of the namespace
186 URI, the namespace separator character, and the local part of the
187 name. If the namespace separator is '\0' then the namespace URI
188 and the local part will be concatenated without any separator.
189 When a namespace is not declared, the name and prefix will be
190 passed through without expansion.
192 XMLPARSEAPI(XML_Parser)
193 XML_ParserCreateNS(const XML_Char * encoding, XML_Char namespaceSeparator);
195 /* Constructs a new parser using the memory management suit referred to
196 by memsuite. If memsuite is NULL, then use the standard library memory
197 suite. If namespaceSeparator is non-NULL it creates a parser with
198 namespace processing as described above. The character pointed at
199 will serve as the namespace separator.
201 All further memory operations used for the created parser will come from
202 the given suite.
204 XMLPARSEAPI(XML_Parser)
205 XML_ParserCreate_MM(const XML_Char * encoding, const XML_Memory_Handling_Suite * memsuite, const XML_Char * namespaceSeparator);
207 /* Prepare a parser object to be re-used. This is particularly
208 valuable when memory allocation overhead is disproportionatly high,
209 such as when a large number of small documnents need to be parsed.
210 All handlers are cleared from the parser, except for the
211 unknownEncodingHandler. The parser's external state is re-initialized
212 except for the values of ns and ns_triplets.
214 Added in Expat 1.95.3.
216 XMLPARSEAPI(XML_Bool)
217 XML_ParserReset(XML_Parser parser, const XML_Char * encoding);
219 /* atts is array of name/value pairs, terminated by 0;
220 names and values are 0 terminated.
222 typedef void (*XML_StartElementHandler) (void *userData, const XML_Char * name, const XML_Char ** atts);
224 typedef void (*XML_EndElementHandler) (void *userData, const XML_Char * name);
226 /* s is not 0 terminated. */
227 typedef void (*XML_CharacterDataHandler) (void *userData, const XML_Char * s, int len);
229 /* target and data are 0 terminated */
230 typedef void (*XML_ProcessingInstructionHandler) (void *userData, const XML_Char * target, const XML_Char * data);
232 /* data is 0 terminated */
233 typedef void (*XML_CommentHandler) (void *userData, const XML_Char * data);
235 typedef void (*XML_StartCdataSectionHandler) (void *userData);
236 typedef void (*XML_EndCdataSectionHandler) (void *userData);
238 /* This is called for any characters in the XML document for which
239 there is no applicable handler. This includes both characters that
240 are part of markup which is of a kind that is not reported
241 (comments, markup declarations), or characters that are part of a
242 construct which could be reported but for which no handler has been
243 supplied. The characters are passed exactly as they were in the XML
244 document except that they will be encoded in UTF-8 or UTF-16.
245 Line boundaries are not normalized. Note that a byte order mark
246 character is not passed to the default handler. There are no
247 guarantees about how characters are divided between calls to the
248 default handler: for example, a comment might be split between
249 multiple calls.
251 typedef void (*XML_DefaultHandler) (void *userData, const XML_Char * s, int len);
253 /* This is called for the start of the DOCTYPE declaration, before
254 any DTD or internal subset is parsed.
256 typedef void (*XML_StartDoctypeDeclHandler) (void *userData, const XML_Char * doctypeName, const XML_Char * sysid, const XML_Char * pubid, int has_internal_subset);
258 /* This is called for the start of the DOCTYPE declaration when the
259 closing > is encountered, but after processing any external
260 subset.
262 typedef void (*XML_EndDoctypeDeclHandler) (void *userData);
264 /* This is called for entity declarations. The is_parameter_entity
265 argument will be non-zero if the entity is a parameter entity, zero
266 otherwise.
268 For internal entities (<!ENTITY foo "bar">), value will
269 be non-NULL and systemId, publicID, and notationName will be NULL.
270 The value string is NOT nul-terminated; the length is provided in
271 the value_length argument. Since it is legal to have zero-length
272 values, do not use this argument to test for internal entities.
274 For external entities, value will be NULL and systemId will be
275 non-NULL. The publicId argument will be NULL unless a public
276 identifier was provided. The notationName argument will have a
277 non-NULL value only for unparsed entity declarations.
279 Note that is_parameter_entity can't be changed to XML_Bool, since
280 that would break binary compatibility.
282 typedef void (*XML_EntityDeclHandler) (void *userData, const XML_Char * entityName, int is_parameter_entity, const XML_Char * value, int value_length, const XML_Char * base, const XML_Char * systemId, const XML_Char * publicId, const XML_Char * notationName);
284 XMLPARSEAPI(void)
285 XML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler);
287 /* OBSOLETE -- OBSOLETE -- OBSOLETE
288 This handler has been superceded by the EntityDeclHandler above.
289 It is provided here for backward compatibility.
291 This is called for a declaration of an unparsed (NDATA) entity.
292 The base argument is whatever was set by XML_SetBase. The
293 entityName, systemId and notationName arguments will never be
294 NULL. The other arguments may be.
296 typedef void (*XML_UnparsedEntityDeclHandler) (void *userData, const XML_Char * entityName, const XML_Char * base, const XML_Char * systemId, const XML_Char * publicId, const XML_Char * notationName);
298 /* This is called for a declaration of notation. The base argument is
299 whatever was set by XML_SetBase. The notationName will never be
300 NULL. The other arguments can be.
302 typedef void (*XML_NotationDeclHandler) (void *userData, const XML_Char * notationName, const XML_Char * base, const XML_Char * systemId, const XML_Char * publicId);
304 /* When namespace processing is enabled, these are called once for
305 each namespace declaration. The call to the start and end element
306 handlers occur between the calls to the start and end namespace
307 declaration handlers. For an xmlns attribute, prefix will be
308 NULL. For an xmlns="" attribute, uri will be NULL.
310 typedef void (*XML_StartNamespaceDeclHandler) (void *userData, const XML_Char * prefix, const XML_Char * uri);
312 typedef void (*XML_EndNamespaceDeclHandler) (void *userData, const XML_Char * prefix);
314 /* This is called if the document is not standalone, that is, it has an
315 external subset or a reference to a parameter entity, but does not
316 have standalone="yes". If this handler returns 0, then processing
317 will not continue, and the parser will return a
318 XML_ERROR_NOT_STANDALONE error.
319 If parameter entity parsing is enabled, then in addition to the
320 conditions above this handler will only be called if the referenced
321 entity was actually read.
323 typedef int (*XML_NotStandaloneHandler) (void *userData);
325 /* This is called for a reference to an external parsed general
326 entity. The referenced entity is not automatically parsed. The
327 application can parse it immediately or later using
328 XML_ExternalEntityParserCreate.
330 The parser argument is the parser parsing the entity containing the
331 reference; it can be passed as the parser argument to
332 XML_ExternalEntityParserCreate. The systemId argument is the
333 system identifier as specified in the entity declaration; it will
334 not be NULL.
336 The base argument is the system identifier that should be used as
337 the base for resolving systemId if systemId was relative; this is
338 set by XML_SetBase; it may be NULL.
340 The publicId argument is the public identifier as specified in the
341 entity declaration, or NULL if none was specified; the whitespace
342 in the public identifier will have been normalized as required by
343 the XML spec.
345 The context argument specifies the parsing context in the format
346 expected by the context argument to XML_ExternalEntityParserCreate;
347 context is valid only until the handler returns, so if the
348 referenced entity is to be parsed later, it must be copied.
350 The handler should return 0 if processing should not continue
351 because of a fatal error in the handling of the external entity.
352 In this case the calling parser will return an
353 XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
355 Note that unlike other handlers the first argument is the parser,
356 not userData.
358 typedef int (*XML_ExternalEntityRefHandler) (XML_Parser parser, const XML_Char * context, const XML_Char * base, const XML_Char * systemId, const XML_Char * publicId);
360 /* This is called in two situations:
361 1) An entity reference is encountered for which no declaration
362 has been read *and* this is not an error.
363 2) An internal entity reference is read, but not expanded, because
364 XML_SetDefaultHandler has been called.
365 Note: skipped parameter entities in declarations and skipped general
366 entities in attribute values cannot be reported, because
367 the event would be out of sync with the reporting of the
368 declarations or attribute values
370 typedef void (*XML_SkippedEntityHandler) (void *userData, const XML_Char * entityName, int is_parameter_entity);
372 /* This structure is filled in by the XML_UnknownEncodingHandler to
373 provide information to the parser about encodings that are unknown
374 to the parser.
376 The map[b] member gives information about byte sequences whose
377 first byte is b.
379 If map[b] is c where c is >= 0, then b by itself encodes the
380 Unicode scalar value c.
382 If map[b] is -1, then the byte sequence is malformed.
384 If map[b] is -n, where n >= 2, then b is the first byte of an
385 n-byte sequence that encodes a single Unicode scalar value.
387 The data member will be passed as the first argument to the convert
388 function.
390 The convert function is used to convert multibyte sequences; s will
391 point to a n-byte sequence where map[(unsigned char)*s] == -n. The
392 convert function must return the Unicode scalar value represented
393 by this byte sequence or -1 if the byte sequence is malformed.
395 The convert function may be NULL if the encoding is a single-byte
396 encoding, that is if map[b] >= -1 for all bytes b.
398 When the parser is finished with the encoding, then if release is
399 not NULL, it will call release passing it the data member; once
400 release has been called, the convert function will not be called
401 again.
403 Expat places certain restrictions on the encodings that are supported
404 using this mechanism.
406 1. Every ASCII character that can appear in a well-formed XML document,
407 other than the characters
409 $@\^`{}~
411 must be represented by a single byte, and that byte must be the
412 same byte that represents that character in ASCII.
414 2. No character may require more than 4 bytes to encode.
416 3. All characters encoded must have Unicode scalar values <=
417 0xFFFF, (i.e., characters that would be encoded by surrogates in
418 UTF-16 are not allowed). Note that this restriction doesn't
419 apply to the built-in support for UTF-8 and UTF-16.
421 4. No Unicode character may be encoded by more than one distinct
422 sequence of bytes.
424 typedef struct {
425 int map[256];
426 void *data;
427 int (*convert) (void *data, const char *s);
428 void (*release) (void *data);
429 } XML_Encoding;
431 /* This is called for an encoding that is unknown to the parser.
433 The encodingHandlerData argument is that which was passed as the
434 second argument to XML_SetUnknownEncodingHandler.
436 The name argument gives the name of the encoding as specified in
437 the encoding declaration.
439 If the callback can provide information about the encoding, it must
440 fill in the XML_Encoding structure, and return 1. Otherwise it
441 must return 0.
443 If info does not describe a suitable encoding, then the parser will
444 return an XML_UNKNOWN_ENCODING error.
446 typedef int (*XML_UnknownEncodingHandler) (void *encodingHandlerData, const XML_Char * name, XML_Encoding * info);
448 XMLPARSEAPI(void)
449 XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end);
451 XMLPARSEAPI(void)
452 XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
454 XMLPARSEAPI(void)
455 XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
457 XMLPARSEAPI(void)
458 XML_SetCharacterDataHandler(XML_Parser parser, XML_CharacterDataHandler handler);
460 XMLPARSEAPI(void)
461 XML_SetProcessingInstructionHandler(XML_Parser parser, XML_ProcessingInstructionHandler handler);
462 XMLPARSEAPI(void)
463 XML_SetCommentHandler(XML_Parser parser, XML_CommentHandler handler);
465 XMLPARSEAPI(void)
466 XML_SetCdataSectionHandler(XML_Parser parser, XML_StartCdataSectionHandler start, XML_EndCdataSectionHandler end);
468 XMLPARSEAPI(void)
469 XML_SetStartCdataSectionHandler(XML_Parser parser, XML_StartCdataSectionHandler start);
471 XMLPARSEAPI(void)
472 XML_SetEndCdataSectionHandler(XML_Parser parser, XML_EndCdataSectionHandler end);
474 /* This sets the default handler and also inhibits expansion of
475 internal entities. These entity references will be passed to the
476 default handler, or to the skipped entity handler, if one is set.
478 XMLPARSEAPI(void)
479 XML_SetDefaultHandler(XML_Parser parser, XML_DefaultHandler handler);
481 /* This sets the default handler but does not inhibit expansion of
482 internal entities. The entity reference will not be passed to the
483 default handler.
485 XMLPARSEAPI(void)
486 XML_SetDefaultHandlerExpand(XML_Parser parser, XML_DefaultHandler handler);
488 XMLPARSEAPI(void)
489 XML_SetDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start, XML_EndDoctypeDeclHandler end);
491 XMLPARSEAPI(void)
492 XML_SetStartDoctypeDeclHandler(XML_Parser parser, XML_StartDoctypeDeclHandler start);
494 XMLPARSEAPI(void)
495 XML_SetEndDoctypeDeclHandler(XML_Parser parser, XML_EndDoctypeDeclHandler end);
497 XMLPARSEAPI(void)
498 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, XML_UnparsedEntityDeclHandler handler);
500 XMLPARSEAPI(void)
501 XML_SetNotationDeclHandler(XML_Parser parser, XML_NotationDeclHandler handler);
503 XMLPARSEAPI(void)
504 XML_SetNamespaceDeclHandler(XML_Parser parser, XML_StartNamespaceDeclHandler start, XML_EndNamespaceDeclHandler end);
506 XMLPARSEAPI(void)
507 XML_SetStartNamespaceDeclHandler(XML_Parser parser, XML_StartNamespaceDeclHandler start);
509 XMLPARSEAPI(void)
510 XML_SetEndNamespaceDeclHandler(XML_Parser parser, XML_EndNamespaceDeclHandler end);
512 XMLPARSEAPI(void)
513 XML_SetNotStandaloneHandler(XML_Parser parser, XML_NotStandaloneHandler handler);
515 XMLPARSEAPI(void)
516 XML_SetExternalEntityRefHandler(XML_Parser parser, XML_ExternalEntityRefHandler handler);
518 /* If a non-NULL value for arg is specified here, then it will be
519 passed as the first argument to the external entity ref handler
520 instead of the parser object.
522 XMLPARSEAPI(void)
523 XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
525 XMLPARSEAPI(void)
526 XML_SetSkippedEntityHandler(XML_Parser parser, XML_SkippedEntityHandler handler);
528 XMLPARSEAPI(void)
529 XML_SetUnknownEncodingHandler(XML_Parser parser, XML_UnknownEncodingHandler handler, void *encodingHandlerData);
531 /* This can be called within a handler for a start element, end
532 element, processing instruction or character data. It causes the
533 corresponding markup to be passed to the default handler.
535 XMLPARSEAPI(void)
536 XML_DefaultCurrent(XML_Parser parser);
538 /* If do_nst is non-zero, and namespace processing is in effect, and
539 a name has a prefix (i.e. an explicit namespace qualifier) then
540 that name is returned as a triplet in a single string separated by
541 the separator character specified when the parser was created: URI
542 + sep + local_name + sep + prefix.
544 If do_nst is zero, then namespace information is returned in the
545 default manner (URI + sep + local_name) whether or not the name
546 has a prefix.
548 Note: Calling XML_SetReturnNSTriplet after XML_Parse or
549 XML_ParseBuffer has no effect.
552 XMLPARSEAPI(void)
553 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
555 /* This value is passed as the userData argument to callbacks. */
556 XMLPARSEAPI(void)
557 XML_SetUserData(XML_Parser parser, void *userData);
559 /* Returns the last value set by XML_SetUserData or NULL. */
560 #define XML_GetUserData(parser) (*(void **)(parser))
562 /* This is equivalent to supplying an encoding argument to
563 XML_ParserCreate. On success XML_SetEncoding returns non-zero,
564 zero otherwise.
565 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
566 has no effect and returns zero.
568 XMLPARSEAPI(int)
569 XML_SetEncoding(XML_Parser parser, const XML_Char * encoding);
571 /* If this function is called, then the parser will be passed as the
572 first argument to callbacks instead of userData. The userData will
573 still be accessible using XML_GetUserData.
575 XMLPARSEAPI(void)
576 XML_UseParserAsHandlerArg(XML_Parser parser);
578 /* If useDTD == XML_TRUE is passed to this function, then the parser
579 will assume that there is an external subset, even if none is
580 specified in the document. In such a case the parser will call the
581 externalEntityRefHandler with a value of NULL for the systemId
582 argument (the publicId and context arguments will be NULL as well).
583 Note: If this function is called, then this must be done before
584 the first call to XML_Parse or XML_ParseBuffer, since it will
585 have no effect after that. Returns
586 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
587 Note: If the document does not have a DOCTYPE declaration at all,
588 then startDoctypeDeclHandler and endDoctypeDeclHandler will not
589 be called, despite an external subset being parsed.
590 Note: If XML_DTD is not defined when Expat is compiled, returns
591 XML_ERROR_FEATURE_REQUIRES_XML_DTD.
593 XMLPARSEAPI(enum XML_Error)
594 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
596 /* Sets the base to be used for resolving relative URIs in system
597 identifiers in declarations. Resolving relative identifiers is
598 left to the application: this value will be passed through as the
599 base argument to the XML_ExternalEntityRefHandler,
600 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
601 argument will be copied. Returns zero if out of memory, non-zero
602 otherwise.
604 XMLPARSEAPI(int)
605 XML_SetBase(XML_Parser parser, const XML_Char * base);
607 XMLPARSEAPI(const XML_Char *)
608 XML_GetBase(XML_Parser parser);
610 /* Returns the number of the attribute/value pairs passed in last call
611 to the XML_StartElementHandler that were specified in the start-tag
612 rather than defaulted. Each attribute/value pair counts as 2; thus
613 this correspondds to an index into the atts array passed to the
614 XML_StartElementHandler.
616 XMLPARSEAPI(int)
617 XML_GetSpecifiedAttributeCount(XML_Parser parser);
619 /* Returns the index of the ID attribute passed in the last call to
620 XML_StartElementHandler, or -1 if there is no ID attribute. Each
621 attribute/value pair counts as 2; thus this correspondds to an
622 index into the atts array passed to the XML_StartElementHandler.
624 XMLPARSEAPI(int)
625 XML_GetIdAttributeIndex(XML_Parser parser);
627 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
628 detected. The last call to XML_Parse must have isFinal true; len
629 may be zero for this call (or any other).
631 The XML_Status enum gives the possible return values for the
632 XML_Parse and XML_ParseBuffer functions. Though the return values
633 for these functions has always been described as a Boolean value,
634 the implementation, at least for the 1.95.x series, has always
635 returned exactly one of these values. The preprocessor #defines
636 are included so this stanza can be added to code that still needs
637 to support older versions of Expat 1.95.x:
639 #ifndef XML_STATUS_OK
640 #define XML_STATUS_OK 1
641 #define XML_STATUS_ERROR 0
642 #endif
644 Otherwise, the #define hackery is quite ugly and would have been dropped.
646 enum XML_Status {
647 XML_STATUS_ERROR = 0,
648 #define XML_STATUS_ERROR XML_STATUS_ERROR
649 XML_STATUS_OK = 1
650 #define XML_STATUS_OK XML_STATUS_OK
653 XMLPARSEAPI(enum XML_Status)
654 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
656 XMLPARSEAPI(void *)
657 XML_GetBuffer(XML_Parser parser, int len);
659 XMLPARSEAPI(enum XML_Status)
660 XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
662 /* Creates an XML_Parser object that can parse an external general
663 entity; context is a '\0'-terminated string specifying the parse
664 context; encoding is a '\0'-terminated string giving the name of
665 the externally specified encoding, or NULL if there is no
666 externally specified encoding. The context string consists of a
667 sequence of tokens separated by formfeeds (\f); a token consisting
668 of a name specifies that the general entity of the name is open; a
669 token of the form prefix=uri specifies the namespace for a
670 particular prefix; a token of the form =uri specifies the default
671 namespace. This can be called at any point after the first call to
672 an ExternalEntityRefHandler so longer as the parser has not yet
673 been freed. The new parser is completely independent and may
674 safely be used in a separate thread. The handlers and userData are
675 initialized from the parser argument. Returns 0 if out of memory.
676 Otherwise returns a new XML_Parser object.
678 XMLPARSEAPI(XML_Parser)
679 XML_ExternalEntityParserCreate(XML_Parser parser, const XML_Char * context, const XML_Char * encoding);
681 enum XML_ParamEntityParsing {
682 XML_PARAM_ENTITY_PARSING_NEVER,
683 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
684 XML_PARAM_ENTITY_PARSING_ALWAYS
687 /* Controls parsing of parameter entities (including the external DTD
688 subset). If parsing of parameter entities is enabled, then
689 references to external parameter entities (including the external
690 DTD subset) will be passed to the handler set with
691 XML_SetExternalEntityRefHandler. The context passed will be 0.
693 Unlike external general entities, external parameter entities can
694 only be parsed synchronously. If the external parameter entity is
695 to be parsed, it must be parsed during the call to the external
696 entity ref handler: the complete sequence of
697 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
698 XML_ParserFree calls must be made during this call. After
699 XML_ExternalEntityParserCreate has been called to create the parser
700 for the external parameter entity (context must be 0 for this
701 call), it is illegal to make any calls on the old parser until
702 XML_ParserFree has been called on the newly created parser.
703 If the library has been compiled without support for parameter
704 entity parsing (ie without XML_DTD being defined), then
705 XML_SetParamEntityParsing will return 0 if parsing of parameter
706 entities is requested; otherwise it will return non-zero.
707 Note: If XML_SetParamEntityParsing is called after XML_Parse or
708 XML_ParseBuffer, then it has no effect and will always return 0.
710 XMLPARSEAPI(int)
711 XML_SetParamEntityParsing(XML_Parser parser, enum XML_ParamEntityParsing parsing);
713 /* If XML_Parse or XML_ParseBuffer have returned 0, then
714 XML_GetErrorCode returns information about the error.
716 XMLPARSEAPI(enum XML_Error)
717 XML_GetErrorCode(XML_Parser parser);
719 /* These functions return information about the current parse
720 location. They may be called when XML_Parse or XML_ParseBuffer
721 return 0; in this case the location is the location of the
722 character at which the error was detected.
724 They may also be called from any other callback called to report
725 some parse event; in this the location is the location of the first
726 of the sequence of characters that generated the event.
728 XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
729 XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
730 XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
732 /* Return the number of bytes in the current event.
733 Returns 0 if the event is in an internal entity.
735 XMLPARSEAPI(int)
736 XML_GetCurrentByteCount(XML_Parser parser);
738 /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
739 the integer pointed to by offset to the offset within this buffer
740 of the current parse position, and sets the integer pointed to by size
741 to the size of this buffer (the number of input bytes). Otherwise
742 returns a NULL pointer. Also returns a NULL pointer if a parse isn't
743 active.
745 NOTE: The character pointer returned should not be used outside
746 the handler that makes the call.
748 XMLPARSEAPI(const char *)
749 XML_GetInputContext(XML_Parser parser, int *offset, int *size);
751 /* For backwards compatibility with previous versions. */
752 #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
753 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
754 #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
756 /* Frees memory used by the parser. */
757 XMLPARSEAPI(void)
758 XML_ParserFree(XML_Parser parser);
760 /* Returns a string describing the error. */
761 XMLPARSEAPI(const XML_LChar *)
762 XML_ErrorString(enum XML_Error code);
764 /* Return a string containing the version number of this expat */
765 XMLPARSEAPI(const XML_LChar *)
766 XML_ExpatVersion(void);
768 typedef struct {
769 int major;
770 int minor;
771 int micro;
772 } XML_Expat_Version;
774 /* Return an XML_Expat_Version structure containing numeric version
775 number information for this version of expat.
777 XMLPARSEAPI(XML_Expat_Version)
778 XML_ExpatVersionInfo(void);
780 /* Added in Expat 1.95.5. */
781 enum XML_FeatureEnum {
782 XML_FEATURE_END = 0,
783 XML_FEATURE_UNICODE,
784 XML_FEATURE_UNICODE_WCHAR_T,
785 XML_FEATURE_DTD,
786 XML_FEATURE_CONTEXT_BYTES,
787 XML_FEATURE_MIN_SIZE,
788 XML_FEATURE_SIZEOF_XML_CHAR,
789 XML_FEATURE_SIZEOF_XML_LCHAR
790 /* Additional features must be added to the end of this enum. */
793 typedef struct {
794 enum XML_FeatureEnum feature;
795 XML_LChar *name;
796 long int value;
797 } XML_Feature;
799 XMLPARSEAPI(const XML_Feature *)
800 XML_GetFeatureList(void);
802 /* Expat follows the GNU/Linux convention of odd number minor version for
803 beta/development releases and even number minor version for stable
804 releases. Micro is bumped with each release, and set to 0 with each
805 change to major or minor version.
807 #define XML_MAJOR_VERSION 1
808 #define XML_MINOR_VERSION 95
809 #define XML_MICRO_VERSION 5
811 #ifdef __cplusplus
813 #endif
814 #endif /* not XmlParse_INCLUDED */