1 /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
2 See the file COPYING for copying permission.
5 #ifndef XmlParse_INCLUDED
6 #define XmlParse_INCLUDED 1
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
20 #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
22 #define XMLPARSEAPI(type) type __cdecl
24 #define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl
27 #define XMLPARSEAPI(type) type
29 #endif /* not defined XMLPARSEAPI */
35 #ifdef XML_UNICODE_WCHAR_T
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;
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)
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 {
99 enum XML_Content_Quant {
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;
127 enum XML_Content_Type type;
128 enum XML_Content_Quant quant;
130 unsigned int numchildren;
131 XML_Content * children;
135 /* This is called for an element declaration. See above for
136 description of the model argument. It's the caller's responsibility
137 to free model when finished with it.
139 typedef void (*XML_ElementDeclHandler) (void *userData,
140 const XML_Char *name,
144 XML_SetElementDeclHandler(XML_Parser parser,
145 XML_ElementDeclHandler eldecl);
147 /* The Attlist declaration handler is called for *each* attribute. So
148 a single Attlist declaration with multiple attributes declared will
149 generate multiple calls to this handler. The "default" parameter
150 may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
151 keyword. The "isrequired" parameter will be true and the default
152 value will be NULL in the case of "#REQUIRED". If "isrequired" is
153 true and default is non-NULL, then this is a "#FIXED" default.
155 typedef void (*XML_AttlistDeclHandler) (void *userData,
156 const XML_Char *elname,
157 const XML_Char *attname,
158 const XML_Char *att_type,
159 const XML_Char *dflt,
163 XML_SetAttlistDeclHandler(XML_Parser parser,
164 XML_AttlistDeclHandler attdecl);
166 /* The XML declaration handler is called for *both* XML declarations
167 and text declarations. The way to distinguish is that the version
168 parameter will be NULL for text declarations. The encoding
169 parameter may be NULL for XML declarations. The standalone
170 parameter will be -1, 0, or 1 indicating respectively that there
171 was no standalone parameter in the declaration, that it was given
172 as no, or that it was given as yes.
174 typedef void (*XML_XmlDeclHandler) (void *userData,
175 const XML_Char *version,
176 const XML_Char *encoding,
180 XML_SetXmlDeclHandler(XML_Parser parser,
181 XML_XmlDeclHandler xmldecl);
185 void *(*malloc_fcn)(size_t size);
186 void *(*realloc_fcn)(void *ptr, size_t size);
187 void (*free_fcn)(void *ptr);
188 } XML_Memory_Handling_Suite;
190 /* Constructs a new parser; encoding is the encoding specified by the
191 external protocol or NULL if there is none specified.
193 XMLPARSEAPI(XML_Parser)
194 XML_ParserCreate(const XML_Char *encoding);
196 /* Constructs a new parser and namespace processor. Element type
197 names and attribute names that belong to a namespace will be
198 expanded; unprefixed attribute names are never expanded; unprefixed
199 element type names are expanded only if there is a default
200 namespace. The expanded name is the concatenation of the namespace
201 URI, the namespace separator character, and the local part of the
202 name. If the namespace separator is '\0' then the namespace URI
203 and the local part will be concatenated without any separator.
204 When a namespace is not declared, the name and prefix will be
205 passed through without expansion.
207 XMLPARSEAPI(XML_Parser)
208 XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
211 /* Constructs a new parser using the memory management suit referred to
212 by memsuite. If memsuite is NULL, then use the standard library memory
213 suite. If namespaceSeparator is non-NULL it creates a parser with
214 namespace processing as described above. The character pointed at
215 will serve as the namespace separator.
217 All further memory operations used for the created parser will come from
220 XMLPARSEAPI(XML_Parser)
221 XML_ParserCreate_MM(const XML_Char *encoding,
222 const XML_Memory_Handling_Suite *memsuite,
223 const XML_Char *namespaceSeparator);
225 /* Prepare a parser object to be re-used. This is particularly
226 valuable when memory allocation overhead is disproportionatly high,
227 such as when a large number of small documnents need to be parsed.
228 All handlers are cleared from the parser, except for the
229 unknownEncodingHandler. The parser's external state is re-initialized
230 except for the values of ns and ns_triplets.
232 Added in Expat 1.95.3.
234 XMLPARSEAPI(XML_Bool)
235 XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
237 /* atts is array of name/value pairs, terminated by 0;
238 names and values are 0 terminated.
240 typedef void (*XML_StartElementHandler)(void *userData,
241 const XML_Char *name,
242 const XML_Char **atts);
244 typedef void (*XML_EndElementHandler)(void *userData,
245 const XML_Char *name);
248 /* s is not 0 terminated. */
249 typedef void (*XML_CharacterDataHandler)(void *userData,
253 /* target and data are 0 terminated */
254 typedef void (*XML_ProcessingInstructionHandler)(void *userData,
255 const XML_Char *target,
256 const XML_Char *data);
258 /* data is 0 terminated */
259 typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
261 typedef void (*XML_StartCdataSectionHandler)(void *userData);
262 typedef void (*XML_EndCdataSectionHandler)(void *userData);
264 /* This is called for any characters in the XML document for which
265 there is no applicable handler. This includes both characters that
266 are part of markup which is of a kind that is not reported
267 (comments, markup declarations), or characters that are part of a
268 construct which could be reported but for which no handler has been
269 supplied. The characters are passed exactly as they were in the XML
270 document except that they will be encoded in UTF-8 or UTF-16.
271 Line boundaries are not normalized. Note that a byte order mark
272 character is not passed to the default handler. There are no
273 guarantees about how characters are divided between calls to the
274 default handler: for example, a comment might be split between
277 typedef void (*XML_DefaultHandler)(void *userData,
281 /* This is called for the start of the DOCTYPE declaration, before
282 any DTD or internal subset is parsed.
284 typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
285 const XML_Char *doctypeName,
286 const XML_Char *sysid,
287 const XML_Char *pubid,
288 int has_internal_subset);
290 /* This is called for the start of the DOCTYPE declaration when the
291 closing > is encountered, but after processing any external
294 typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
296 /* This is called for entity declarations. The is_parameter_entity
297 argument will be non-zero if the entity is a parameter entity, zero
300 For internal entities (<!ENTITY foo "bar">), value will
301 be non-NULL and systemId, publicID, and notationName will be NULL.
302 The value string is NOT nul-terminated; the length is provided in
303 the value_length argument. Since it is legal to have zero-length
304 values, do not use this argument to test for internal entities.
306 For external entities, value will be NULL and systemId will be
307 non-NULL. The publicId argument will be NULL unless a public
308 identifier was provided. The notationName argument will have a
309 non-NULL value only for unparsed entity declarations.
311 Note that is_parameter_entity can't be changed to XML_Bool, since
312 that would break binary compatibility.
314 typedef void (*XML_EntityDeclHandler) (void *userData,
315 const XML_Char *entityName,
316 int is_parameter_entity,
317 const XML_Char *value,
319 const XML_Char *base,
320 const XML_Char *systemId,
321 const XML_Char *publicId,
322 const XML_Char *notationName);
325 XML_SetEntityDeclHandler(XML_Parser parser,
326 XML_EntityDeclHandler handler);
328 /* OBSOLETE -- OBSOLETE -- OBSOLETE
329 This handler has been superceded by the EntityDeclHandler above.
330 It is provided here for backward compatibility.
332 This is called for a declaration of an unparsed (NDATA) entity.
333 The base argument is whatever was set by XML_SetBase. The
334 entityName, systemId and notationName arguments will never be
335 NULL. The other arguments may be.
337 typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
338 const XML_Char *entityName,
339 const XML_Char *base,
340 const XML_Char *systemId,
341 const XML_Char *publicId,
342 const XML_Char *notationName);
344 /* This is called for a declaration of notation. The base argument is
345 whatever was set by XML_SetBase. The notationName will never be
346 NULL. The other arguments can be.
348 typedef void (*XML_NotationDeclHandler)(void *userData,
349 const XML_Char *notationName,
350 const XML_Char *base,
351 const XML_Char *systemId,
352 const XML_Char *publicId);
354 /* When namespace processing is enabled, these are called once for
355 each namespace declaration. The call to the start and end element
356 handlers occur between the calls to the start and end namespace
357 declaration handlers. For an xmlns attribute, prefix will be
358 NULL. For an xmlns="" attribute, uri will be NULL.
360 typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
361 const XML_Char *prefix,
362 const XML_Char *uri);
364 typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
365 const XML_Char *prefix);
367 /* This is called if the document is not standalone, that is, it has an
368 external subset or a reference to a parameter entity, but does not
369 have standalone="yes". If this handler returns 0, then processing
370 will not continue, and the parser will return a
371 XML_ERROR_NOT_STANDALONE error.
372 If parameter entity parsing is enabled, then in addition to the
373 conditions above this handler will only be called if the referenced
374 entity was actually read.
376 typedef int (*XML_NotStandaloneHandler)(void *userData);
378 /* This is called for a reference to an external parsed general
379 entity. The referenced entity is not automatically parsed. The
380 application can parse it immediately or later using
381 XML_ExternalEntityParserCreate.
383 The parser argument is the parser parsing the entity containing the
384 reference; it can be passed as the parser argument to
385 XML_ExternalEntityParserCreate. The systemId argument is the
386 system identifier as specified in the entity declaration; it will
389 The base argument is the system identifier that should be used as
390 the base for resolving systemId if systemId was relative; this is
391 set by XML_SetBase; it may be NULL.
393 The publicId argument is the public identifier as specified in the
394 entity declaration, or NULL if none was specified; the whitespace
395 in the public identifier will have been normalized as required by
398 The context argument specifies the parsing context in the format
399 expected by the context argument to XML_ExternalEntityParserCreate;
400 context is valid only until the handler returns, so if the
401 referenced entity is to be parsed later, it must be copied.
403 The handler should return 0 if processing should not continue
404 because of a fatal error in the handling of the external entity.
405 In this case the calling parser will return an
406 XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
408 Note that unlike other handlers the first argument is the parser,
411 typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
412 const XML_Char *context,
413 const XML_Char *base,
414 const XML_Char *systemId,
415 const XML_Char *publicId);
417 /* This is called in two situations:
418 1) An entity reference is encountered for which no declaration
419 has been read *and* this is not an error.
420 2) An internal entity reference is read, but not expanded, because
421 XML_SetDefaultHandler has been called.
422 Note: skipped parameter entities in declarations and skipped general
423 entities in attribute values cannot be reported, because
424 the event would be out of sync with the reporting of the
425 declarations or attribute values
427 typedef void (*XML_SkippedEntityHandler)(void *userData,
428 const XML_Char *entityName,
429 int is_parameter_entity);
431 /* This structure is filled in by the XML_UnknownEncodingHandler to
432 provide information to the parser about encodings that are unknown
435 The map[b] member gives information about byte sequences whose
438 If map[b] is c where c is >= 0, then b by itself encodes the
439 Unicode scalar value c.
441 If map[b] is -1, then the byte sequence is malformed.
443 If map[b] is -n, where n >= 2, then b is the first byte of an
444 n-byte sequence that encodes a single Unicode scalar value.
446 The data member will be passed as the first argument to the convert
449 The convert function is used to convert multibyte sequences; s will
450 point to a n-byte sequence where map[(unsigned char)*s] == -n. The
451 convert function must return the Unicode scalar value represented
452 by this byte sequence or -1 if the byte sequence is malformed.
454 The convert function may be NULL if the encoding is a single-byte
455 encoding, that is if map[b] >= -1 for all bytes b.
457 When the parser is finished with the encoding, then if release is
458 not NULL, it will call release passing it the data member; once
459 release has been called, the convert function will not be called
462 Expat places certain restrictions on the encodings that are supported
463 using this mechanism.
465 1. Every ASCII character that can appear in a well-formed XML document,
466 other than the characters
470 must be represented by a single byte, and that byte must be the
471 same byte that represents that character in ASCII.
473 2. No character may require more than 4 bytes to encode.
475 3. All characters encoded must have Unicode scalar values <=
476 0xFFFF, (i.e., characters that would be encoded by surrogates in
477 UTF-16 are not allowed). Note that this restriction doesn't
478 apply to the built-in support for UTF-8 and UTF-16.
480 4. No Unicode character may be encoded by more than one distinct
486 int (*convert)(void *data, const char *s);
487 void (*release)(void *data);
490 /* This is called for an encoding that is unknown to the parser.
492 The encodingHandlerData argument is that which was passed as the
493 second argument to XML_SetUnknownEncodingHandler.
495 The name argument gives the name of the encoding as specified in
496 the encoding declaration.
498 If the callback can provide information about the encoding, it must
499 fill in the XML_Encoding structure, and return 1. Otherwise it
502 If info does not describe a suitable encoding, then the parser will
503 return an XML_UNKNOWN_ENCODING error.
505 typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
506 const XML_Char *name,
510 XML_SetElementHandler(XML_Parser parser,
511 XML_StartElementHandler start,
512 XML_EndElementHandler end);
515 XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
518 XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
521 XML_SetCharacterDataHandler(XML_Parser parser,
522 XML_CharacterDataHandler handler);
525 XML_SetProcessingInstructionHandler(XML_Parser parser,
526 XML_ProcessingInstructionHandler handler);
528 XML_SetCommentHandler(XML_Parser parser,
529 XML_CommentHandler handler);
532 XML_SetCdataSectionHandler(XML_Parser parser,
533 XML_StartCdataSectionHandler start,
534 XML_EndCdataSectionHandler end);
537 XML_SetStartCdataSectionHandler(XML_Parser parser,
538 XML_StartCdataSectionHandler start);
541 XML_SetEndCdataSectionHandler(XML_Parser parser,
542 XML_EndCdataSectionHandler end);
544 /* This sets the default handler and also inhibits expansion of
545 internal entities. These entity references will be passed to the
546 default handler, or to the skipped entity handler, if one is set.
549 XML_SetDefaultHandler(XML_Parser parser,
550 XML_DefaultHandler handler);
552 /* This sets the default handler but does not inhibit expansion of
553 internal entities. The entity reference will not be passed to the
557 XML_SetDefaultHandlerExpand(XML_Parser parser,
558 XML_DefaultHandler handler);
561 XML_SetDoctypeDeclHandler(XML_Parser parser,
562 XML_StartDoctypeDeclHandler start,
563 XML_EndDoctypeDeclHandler end);
566 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
567 XML_StartDoctypeDeclHandler start);
570 XML_SetEndDoctypeDeclHandler(XML_Parser parser,
571 XML_EndDoctypeDeclHandler end);
574 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
575 XML_UnparsedEntityDeclHandler handler);
578 XML_SetNotationDeclHandler(XML_Parser parser,
579 XML_NotationDeclHandler handler);
582 XML_SetNamespaceDeclHandler(XML_Parser parser,
583 XML_StartNamespaceDeclHandler start,
584 XML_EndNamespaceDeclHandler end);
587 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
588 XML_StartNamespaceDeclHandler start);
591 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
592 XML_EndNamespaceDeclHandler end);
595 XML_SetNotStandaloneHandler(XML_Parser parser,
596 XML_NotStandaloneHandler handler);
599 XML_SetExternalEntityRefHandler(XML_Parser parser,
600 XML_ExternalEntityRefHandler handler);
602 /* If a non-NULL value for arg is specified here, then it will be
603 passed as the first argument to the external entity ref handler
604 instead of the parser object.
607 XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
610 XML_SetSkippedEntityHandler(XML_Parser parser,
611 XML_SkippedEntityHandler handler);
614 XML_SetUnknownEncodingHandler(XML_Parser parser,
615 XML_UnknownEncodingHandler handler,
616 void *encodingHandlerData);
618 /* This can be called within a handler for a start element, end
619 element, processing instruction or character data. It causes the
620 corresponding markup to be passed to the default handler.
623 XML_DefaultCurrent(XML_Parser parser);
625 /* If do_nst is non-zero, and namespace processing is in effect, and
626 a name has a prefix (i.e. an explicit namespace qualifier) then
627 that name is returned as a triplet in a single string separated by
628 the separator character specified when the parser was created: URI
629 + sep + local_name + sep + prefix.
631 If do_nst is zero, then namespace information is returned in the
632 default manner (URI + sep + local_name) whether or not the name
635 Note: Calling XML_SetReturnNSTriplet after XML_Parse or
636 XML_ParseBuffer has no effect.
640 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
642 /* This value is passed as the userData argument to callbacks. */
644 XML_SetUserData(XML_Parser parser, void *userData);
646 /* Returns the last value set by XML_SetUserData or NULL. */
647 #define XML_GetUserData(parser) (*(void **)(parser))
649 /* This is equivalent to supplying an encoding argument to
650 XML_ParserCreate. On success XML_SetEncoding returns non-zero,
652 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
653 has no effect and returns zero.
656 XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
658 /* If this function is called, then the parser will be passed as the
659 first argument to callbacks instead of userData. The userData will
660 still be accessible using XML_GetUserData.
663 XML_UseParserAsHandlerArg(XML_Parser parser);
665 /* If useDTD == XML_TRUE is passed to this function, then the parser
666 will assume that there is an external subset, even if none is
667 specified in the document. In such a case the parser will call the
668 externalEntityRefHandler with a value of NULL for the systemId
669 argument (the publicId and context arguments will be NULL as well).
670 Note: If this function is called, then this must be done before
671 the first call to XML_Parse or XML_ParseBuffer, since it will
672 have no effect after that. Returns
673 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
674 Note: If the document does not have a DOCTYPE declaration at all,
675 then startDoctypeDeclHandler and endDoctypeDeclHandler will not
676 be called, despite an external subset being parsed.
677 Note: If XML_DTD is not defined when Expat is compiled, returns
678 XML_ERROR_FEATURE_REQUIRES_XML_DTD.
680 XMLPARSEAPI(enum XML_Error)
681 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
684 /* Sets the base to be used for resolving relative URIs in system
685 identifiers in declarations. Resolving relative identifiers is
686 left to the application: this value will be passed through as the
687 base argument to the XML_ExternalEntityRefHandler,
688 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
689 argument will be copied. Returns zero if out of memory, non-zero
693 XML_SetBase(XML_Parser parser, const XML_Char *base);
695 XMLPARSEAPI(const XML_Char *)
696 XML_GetBase(XML_Parser parser);
698 /* Returns the number of the attribute/value pairs passed in last call
699 to the XML_StartElementHandler that were specified in the start-tag
700 rather than defaulted. Each attribute/value pair counts as 2; thus
701 this correspondds to an index into the atts array passed to the
702 XML_StartElementHandler.
705 XML_GetSpecifiedAttributeCount(XML_Parser parser);
707 /* Returns the index of the ID attribute passed in the last call to
708 XML_StartElementHandler, or -1 if there is no ID attribute. Each
709 attribute/value pair counts as 2; thus this correspondds to an
710 index into the atts array passed to the XML_StartElementHandler.
713 XML_GetIdAttributeIndex(XML_Parser parser);
715 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
716 detected. The last call to XML_Parse must have isFinal true; len
717 may be zero for this call (or any other).
719 The XML_Status enum gives the possible return values for the
720 XML_Parse and XML_ParseBuffer functions. Though the return values
721 for these functions has always been described as a Boolean value,
722 the implementation, at least for the 1.95.x series, has always
723 returned exactly one of these values. The preprocessor #defines
724 are included so this stanza can be added to code that still needs
725 to support older versions of Expat 1.95.x:
727 #ifndef XML_STATUS_OK
728 #define XML_STATUS_OK 1
729 #define XML_STATUS_ERROR 0
732 Otherwise, the #define hackery is quite ugly and would have been dropped.
735 XML_STATUS_ERROR = 0,
736 #define XML_STATUS_ERROR XML_STATUS_ERROR
738 #define XML_STATUS_OK XML_STATUS_OK
741 XMLPARSEAPI(enum XML_Status)
742 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
745 XML_GetBuffer(XML_Parser parser, int len);
747 XMLPARSEAPI(enum XML_Status)
748 XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
750 /* Creates an XML_Parser object that can parse an external general
751 entity; context is a '\0'-terminated string specifying the parse
752 context; encoding is a '\0'-terminated string giving the name of
753 the externally specified encoding, or NULL if there is no
754 externally specified encoding. The context string consists of a
755 sequence of tokens separated by formfeeds (\f); a token consisting
756 of a name specifies that the general entity of the name is open; a
757 token of the form prefix=uri specifies the namespace for a
758 particular prefix; a token of the form =uri specifies the default
759 namespace. This can be called at any point after the first call to
760 an ExternalEntityRefHandler so longer as the parser has not yet
761 been freed. The new parser is completely independent and may
762 safely be used in a separate thread. The handlers and userData are
763 initialized from the parser argument. Returns 0 if out of memory.
764 Otherwise returns a new XML_Parser object.
766 XMLPARSEAPI(XML_Parser)
767 XML_ExternalEntityParserCreate(XML_Parser parser,
768 const XML_Char *context,
769 const XML_Char *encoding);
771 enum XML_ParamEntityParsing {
772 XML_PARAM_ENTITY_PARSING_NEVER,
773 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
774 XML_PARAM_ENTITY_PARSING_ALWAYS
777 /* Controls parsing of parameter entities (including the external DTD
778 subset). If parsing of parameter entities is enabled, then
779 references to external parameter entities (including the external
780 DTD subset) will be passed to the handler set with
781 XML_SetExternalEntityRefHandler. The context passed will be 0.
783 Unlike external general entities, external parameter entities can
784 only be parsed synchronously. If the external parameter entity is
785 to be parsed, it must be parsed during the call to the external
786 entity ref handler: the complete sequence of
787 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
788 XML_ParserFree calls must be made during this call. After
789 XML_ExternalEntityParserCreate has been called to create the parser
790 for the external parameter entity (context must be 0 for this
791 call), it is illegal to make any calls on the old parser until
792 XML_ParserFree has been called on the newly created parser.
793 If the library has been compiled without support for parameter
794 entity parsing (ie without XML_DTD being defined), then
795 XML_SetParamEntityParsing will return 0 if parsing of parameter
796 entities is requested; otherwise it will return non-zero.
797 Note: If XML_SetParamEntityParsing is called after XML_Parse or
798 XML_ParseBuffer, then it has no effect and will always return 0.
801 XML_SetParamEntityParsing(XML_Parser parser,
802 enum XML_ParamEntityParsing parsing);
804 /* If XML_Parse or XML_ParseBuffer have returned 0, then
805 XML_GetErrorCode returns information about the error.
807 XMLPARSEAPI(enum XML_Error)
808 XML_GetErrorCode(XML_Parser parser);
810 /* These functions return information about the current parse
811 location. They may be called when XML_Parse or XML_ParseBuffer
812 return 0; in this case the location is the location of the
813 character at which the error was detected.
815 They may also be called from any other callback called to report
816 some parse event; in this the location is the location of the first
817 of the sequence of characters that generated the event.
819 XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
820 XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
821 XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
823 /* Return the number of bytes in the current event.
824 Returns 0 if the event is in an internal entity.
827 XML_GetCurrentByteCount(XML_Parser parser);
829 /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
830 the integer pointed to by offset to the offset within this buffer
831 of the current parse position, and sets the integer pointed to by size
832 to the size of this buffer (the number of input bytes). Otherwise
833 returns a NULL pointer. Also returns a NULL pointer if a parse isn't
836 NOTE: The character pointer returned should not be used outside
837 the handler that makes the call.
839 XMLPARSEAPI(const char *)
840 XML_GetInputContext(XML_Parser parser,
844 /* For backwards compatibility with previous versions. */
845 #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
846 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
847 #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
849 /* Frees memory used by the parser. */
851 XML_ParserFree(XML_Parser parser);
853 /* Returns a string describing the error. */
854 XMLPARSEAPI(const XML_LChar *)
855 XML_ErrorString(enum XML_Error code);
857 /* Return a string containing the version number of this expat */
858 XMLPARSEAPI(const XML_LChar *)
859 XML_ExpatVersion(void);
867 /* Return an XML_Expat_Version structure containing numeric version
868 number information for this version of expat.
870 XMLPARSEAPI(XML_Expat_Version)
871 XML_ExpatVersionInfo(void);
873 /* Added in Expat 1.95.5. */
874 enum XML_FeatureEnum {
877 XML_FEATURE_UNICODE_WCHAR_T,
879 XML_FEATURE_CONTEXT_BYTES,
880 XML_FEATURE_MIN_SIZE,
881 XML_FEATURE_SIZEOF_XML_CHAR,
882 XML_FEATURE_SIZEOF_XML_LCHAR
883 /* Additional features must be added to the end of this enum. */
887 enum XML_FeatureEnum feature;
892 XMLPARSEAPI(const XML_Feature *)
893 XML_GetFeatureList(void);
896 /* Expat follows the GNU/Linux convention of odd number minor version for
897 beta/development releases and even number minor version for stable
898 releases. Micro is bumped with each release, and set to 0 with each
899 change to major or minor version.
901 #define XML_MAJOR_VERSION 1
902 #define XML_MINOR_VERSION 95
903 #define XML_MICRO_VERSION 5
909 #endif /* not XmlParse_INCLUDED */