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
19 #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
20 #define XML_USE_MSC_EXTENSIONS 1
23 /* Expat tries very hard to make the API boundary very specifically
24 defined. There are two macros defined to control this boundary;
25 each of these can be defined before including this header to
26 achieve some different behavior, but doing so it not recommended or
29 XMLCALL - The calling convention to use for all calls across the
30 "library boundary." This will default to cdecl, and
31 try really hard to tell the compiler that's what we
34 XMLIMPORT - Whatever magic is needed to note that a function is
35 to be imported from a dynamically loaded library
36 (.dll, .so, or .sl, depending on your platform).
38 The XMLCALL macro was added in Expat 1.95.7. The only one which is
39 expected to be directly useful in client code is XMLCALL.
41 Note that on at least some Unix versions, the Expat library must be
42 compiled with the cdecl calling convention as the default since
43 system headers may assume the cdecl convention.
46 #if defined(XML_USE_MSC_EXTENSIONS)
47 #define XMLCALL __cdecl
48 #elif defined(__GNUC__) && defined(__i386)
49 #define XMLCALL __attribute__((cdecl))
51 /* For any platform which uses this definition and supports more than
52 one calling convention, we need to extend this definition to
53 declare the convention used on that platform, if it's possible to
56 If this is the case for your platform, please file a bug report
57 with information on how to identify your platform via the C
58 pre-processor and how to specify the same calling convention as the
59 platform's malloc() implementation.
63 #endif /* not defined XMLCALL */
66 #if !defined(XML_STATIC) && !defined(XMLIMPORT)
67 #ifndef XML_BUILDING_EXPAT
68 /* using Expat from an application */
70 #ifdef XML_USE_MSC_EXTENSIONS
71 #define XMLIMPORT __declspec(dllimport)
75 #endif /* not defined XML_STATIC */
77 /* If we didn't define it above, define it away: */
83 #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
89 #ifdef XML_UNICODE_WCHAR_T
93 struct XML_ParserStruct;
94 typedef struct XML_ParserStruct *XML_Parser;
96 #ifdef XML_UNICODE /* Information is UTF-16 encoded. */
97 #ifdef XML_UNICODE_WCHAR_T
98 typedef wchar_t XML_Char;
99 typedef wchar_t XML_LChar;
101 typedef unsigned short XML_Char;
102 typedef char XML_LChar;
103 #endif /* XML_UNICODE_WCHAR_T */
104 #else /* Information is UTF-8 encoded. */
105 typedef char XML_Char;
106 typedef char XML_LChar;
107 #endif /* XML_UNICODE */
109 /* Should this be defined using stdbool.h when C99 is available? */
110 typedef unsigned char XML_Bool;
111 #define XML_TRUE ((XML_Bool) 1)
112 #define XML_FALSE ((XML_Bool) 0)
114 /* The XML_Status enum gives the possible return values for several
115 API functions. The preprocessor #defines are included so this
116 stanza can be added to code that still needs to support older
117 versions of Expat 1.95.x:
119 #ifndef XML_STATUS_OK
120 #define XML_STATUS_OK 1
121 #define XML_STATUS_ERROR 0
124 Otherwise, the #define hackery is quite ugly and would have been
128 XML_STATUS_ERROR = 0,
129 #define XML_STATUS_ERROR XML_STATUS_ERROR
131 #define XML_STATUS_OK XML_STATUS_OK
138 XML_ERROR_NO_ELEMENTS,
139 XML_ERROR_INVALID_TOKEN,
140 XML_ERROR_UNCLOSED_TOKEN,
141 XML_ERROR_PARTIAL_CHAR,
142 XML_ERROR_TAG_MISMATCH,
143 XML_ERROR_DUPLICATE_ATTRIBUTE,
144 XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
145 XML_ERROR_PARAM_ENTITY_REF,
146 XML_ERROR_UNDEFINED_ENTITY,
147 XML_ERROR_RECURSIVE_ENTITY_REF,
148 XML_ERROR_ASYNC_ENTITY,
149 XML_ERROR_BAD_CHAR_REF,
150 XML_ERROR_BINARY_ENTITY_REF,
151 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
152 XML_ERROR_MISPLACED_XML_PI,
153 XML_ERROR_UNKNOWN_ENCODING,
154 XML_ERROR_INCORRECT_ENCODING,
155 XML_ERROR_UNCLOSED_CDATA_SECTION,
156 XML_ERROR_EXTERNAL_ENTITY_HANDLING,
157 XML_ERROR_NOT_STANDALONE,
158 XML_ERROR_UNEXPECTED_STATE,
159 XML_ERROR_ENTITY_DECLARED_IN_PE,
160 XML_ERROR_FEATURE_REQUIRES_XML_DTD,
161 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
162 XML_ERROR_UNBOUND_PREFIX
165 enum XML_Content_Type {
174 enum XML_Content_Quant {
181 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
182 XML_CQUANT_NONE, and the other fields will be zero or NULL.
183 If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
184 numchildren will contain number of elements that may be mixed in
185 and children point to an array of XML_Content cells that will be
186 all of XML_CTYPE_NAME type with no quantification.
188 If type == XML_CTYPE_NAME, then the name points to the name, and
189 the numchildren field will be zero and children will be NULL. The
190 quant fields indicates any quantifiers placed on the name.
192 CHOICE and SEQ will have name NULL, the number of children in
193 numchildren and children will point, recursively, to an array
194 of XML_Content cells.
196 The EMPTY, ANY, and MIXED types will only occur at top level.
199 typedef struct XML_cp XML_Content;
202 enum XML_Content_Type type;
203 enum XML_Content_Quant quant;
205 unsigned int numchildren;
206 XML_Content * children;
210 /* This is called for an element declaration. See above for
211 description of the model argument. It's the caller's responsibility
212 to free model when finished with it.
214 typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData,
215 const XML_Char *name,
219 XML_SetElementDeclHandler(XML_Parser parser,
220 XML_ElementDeclHandler eldecl);
222 /* The Attlist declaration handler is called for *each* attribute. So
223 a single Attlist declaration with multiple attributes declared will
224 generate multiple calls to this handler. The "default" parameter
225 may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
226 keyword. The "isrequired" parameter will be true and the default
227 value will be NULL in the case of "#REQUIRED". If "isrequired" is
228 true and default is non-NULL, then this is a "#FIXED" default.
230 typedef void (XMLCALL *XML_AttlistDeclHandler) (
232 const XML_Char *elname,
233 const XML_Char *attname,
234 const XML_Char *att_type,
235 const XML_Char *dflt,
239 XML_SetAttlistDeclHandler(XML_Parser parser,
240 XML_AttlistDeclHandler attdecl);
242 /* The XML declaration handler is called for *both* XML declarations
243 and text declarations. The way to distinguish is that the version
244 parameter will be NULL for text declarations. The encoding
245 parameter may be NULL for XML declarations. The standalone
246 parameter will be -1, 0, or 1 indicating respectively that there
247 was no standalone parameter in the declaration, that it was given
248 as no, or that it was given as yes.
250 typedef void (XMLCALL *XML_XmlDeclHandler) (void *userData,
251 const XML_Char *version,
252 const XML_Char *encoding,
256 XML_SetXmlDeclHandler(XML_Parser parser,
257 XML_XmlDeclHandler xmldecl);
261 void *(XMLCALL *malloc_fcn)(size_t size);
262 void *(XMLCALL *realloc_fcn)(void *ptr, size_t size);
263 void (XMLCALL *free_fcn)(void *ptr);
264 } XML_Memory_Handling_Suite;
266 /* Constructs a new parser; encoding is the encoding specified by the
267 external protocol or NULL if there is none specified.
269 XMLPARSEAPI(XML_Parser)
270 XML_ParserCreate(const XML_Char *encoding);
272 /* Constructs a new parser and namespace processor. Element type
273 names and attribute names that belong to a namespace will be
274 expanded; unprefixed attribute names are never expanded; unprefixed
275 element type names are expanded only if there is a default
276 namespace. The expanded name is the concatenation of the namespace
277 URI, the namespace separator character, and the local part of the
278 name. If the namespace separator is '\0' then the namespace URI
279 and the local part will be concatenated without any separator.
280 When a namespace is not declared, the name and prefix will be
281 passed through without expansion.
283 XMLPARSEAPI(XML_Parser)
284 XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
287 /* Constructs a new parser using the memory management suite referred to
288 by memsuite. If memsuite is NULL, then use the standard library memory
289 suite. If namespaceSeparator is non-NULL it creates a parser with
290 namespace processing as described above. The character pointed at
291 will serve as the namespace separator.
293 All further memory operations used for the created parser will come from
296 XMLPARSEAPI(XML_Parser)
297 XML_ParserCreate_MM(const XML_Char *encoding,
298 const XML_Memory_Handling_Suite *memsuite,
299 const XML_Char *namespaceSeparator);
301 /* Prepare a parser object to be re-used. This is particularly
302 valuable when memory allocation overhead is disproportionatly high,
303 such as when a large number of small documnents need to be parsed.
304 All handlers are cleared from the parser, except for the
305 unknownEncodingHandler. The parser's external state is re-initialized
306 except for the values of ns and ns_triplets.
308 Added in Expat 1.95.3.
310 XMLPARSEAPI(XML_Bool)
311 XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
313 /* atts is array of name/value pairs, terminated by 0;
314 names and values are 0 terminated.
316 typedef void (XMLCALL *XML_StartElementHandler) (void *userData,
317 const XML_Char *name,
318 const XML_Char **atts);
320 typedef void (XMLCALL *XML_EndElementHandler) (void *userData,
321 const XML_Char *name);
324 /* s is not 0 terminated. */
325 typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData,
329 /* target and data are 0 terminated */
330 typedef void (XMLCALL *XML_ProcessingInstructionHandler) (
332 const XML_Char *target,
333 const XML_Char *data);
335 /* data is 0 terminated */
336 typedef void (XMLCALL *XML_CommentHandler) (void *userData,
337 const XML_Char *data);
339 typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData);
340 typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
342 /* This is called for any characters in the XML document for which
343 there is no applicable handler. This includes both characters that
344 are part of markup which is of a kind that is not reported
345 (comments, markup declarations), or characters that are part of a
346 construct which could be reported but for which no handler has been
347 supplied. The characters are passed exactly as they were in the XML
348 document except that they will be encoded in UTF-8 or UTF-16.
349 Line boundaries are not normalized. Note that a byte order mark
350 character is not passed to the default handler. There are no
351 guarantees about how characters are divided between calls to the
352 default handler: for example, a comment might be split between
355 typedef void (XMLCALL *XML_DefaultHandler) (void *userData,
359 /* This is called for the start of the DOCTYPE declaration, before
360 any DTD or internal subset is parsed.
362 typedef void (XMLCALL *XML_StartDoctypeDeclHandler) (
364 const XML_Char *doctypeName,
365 const XML_Char *sysid,
366 const XML_Char *pubid,
367 int has_internal_subset);
369 /* This is called for the start of the DOCTYPE declaration when the
370 closing > is encountered, but after processing any external
373 typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
375 /* This is called for entity declarations. The is_parameter_entity
376 argument will be non-zero if the entity is a parameter entity, zero
379 For internal entities (<!ENTITY foo "bar">), value will
380 be non-NULL and systemId, publicID, and notationName will be NULL.
381 The value string is NOT nul-terminated; the length is provided in
382 the value_length argument. Since it is legal to have zero-length
383 values, do not use this argument to test for internal entities.
385 For external entities, value will be NULL and systemId will be
386 non-NULL. The publicId argument will be NULL unless a public
387 identifier was provided. The notationName argument will have a
388 non-NULL value only for unparsed entity declarations.
390 Note that is_parameter_entity can't be changed to XML_Bool, since
391 that would break binary compatibility.
393 typedef void (XMLCALL *XML_EntityDeclHandler) (
395 const XML_Char *entityName,
396 int is_parameter_entity,
397 const XML_Char *value,
399 const XML_Char *base,
400 const XML_Char *systemId,
401 const XML_Char *publicId,
402 const XML_Char *notationName);
405 XML_SetEntityDeclHandler(XML_Parser parser,
406 XML_EntityDeclHandler handler);
408 /* OBSOLETE -- OBSOLETE -- OBSOLETE
409 This handler has been superceded by the EntityDeclHandler above.
410 It is provided here for backward compatibility.
412 This is called for a declaration of an unparsed (NDATA) entity.
413 The base argument is whatever was set by XML_SetBase. The
414 entityName, systemId and notationName arguments will never be
415 NULL. The other arguments may be.
417 typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) (
419 const XML_Char *entityName,
420 const XML_Char *base,
421 const XML_Char *systemId,
422 const XML_Char *publicId,
423 const XML_Char *notationName);
425 /* This is called for a declaration of notation. The base argument is
426 whatever was set by XML_SetBase. The notationName will never be
427 NULL. The other arguments can be.
429 typedef void (XMLCALL *XML_NotationDeclHandler) (
431 const XML_Char *notationName,
432 const XML_Char *base,
433 const XML_Char *systemId,
434 const XML_Char *publicId);
436 /* When namespace processing is enabled, these are called once for
437 each namespace declaration. The call to the start and end element
438 handlers occur between the calls to the start and end namespace
439 declaration handlers. For an xmlns attribute, prefix will be
440 NULL. For an xmlns="" attribute, uri will be NULL.
442 typedef void (XMLCALL *XML_StartNamespaceDeclHandler) (
444 const XML_Char *prefix,
445 const XML_Char *uri);
447 typedef void (XMLCALL *XML_EndNamespaceDeclHandler) (
449 const XML_Char *prefix);
451 /* This is called if the document is not standalone, that is, it has an
452 external subset or a reference to a parameter entity, but does not
453 have standalone="yes". If this handler returns XML_STATUS_ERROR,
454 then processing will not continue, and the parser will return a
455 XML_ERROR_NOT_STANDALONE error.
456 If parameter entity parsing is enabled, then in addition to the
457 conditions above this handler will only be called if the referenced
458 entity was actually read.
460 typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
462 /* This is called for a reference to an external parsed general
463 entity. The referenced entity is not automatically parsed. The
464 application can parse it immediately or later using
465 XML_ExternalEntityParserCreate.
467 The parser argument is the parser parsing the entity containing the
468 reference; it can be passed as the parser argument to
469 XML_ExternalEntityParserCreate. The systemId argument is the
470 system identifier as specified in the entity declaration; it will
473 The base argument is the system identifier that should be used as
474 the base for resolving systemId if systemId was relative; this is
475 set by XML_SetBase; it may be NULL.
477 The publicId argument is the public identifier as specified in the
478 entity declaration, or NULL if none was specified; the whitespace
479 in the public identifier will have been normalized as required by
482 The context argument specifies the parsing context in the format
483 expected by the context argument to XML_ExternalEntityParserCreate;
484 context is valid only until the handler returns, so if the
485 referenced entity is to be parsed later, it must be copied.
486 context is NULL only when the entity is a parameter entity.
488 The handler should return XML_STATUS_ERROR if processing should not
489 continue because of a fatal error in the handling of the external
490 entity. In this case the calling parser will return an
491 XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
493 Note that unlike other handlers the first argument is the parser,
496 typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
498 const XML_Char *context,
499 const XML_Char *base,
500 const XML_Char *systemId,
501 const XML_Char *publicId);
503 /* This is called in two situations:
504 1) An entity reference is encountered for which no declaration
505 has been read *and* this is not an error.
506 2) An internal entity reference is read, but not expanded, because
507 XML_SetDefaultHandler has been called.
508 Note: skipped parameter entities in declarations and skipped general
509 entities in attribute values cannot be reported, because
510 the event would be out of sync with the reporting of the
511 declarations or attribute values
513 typedef void (XMLCALL *XML_SkippedEntityHandler) (
515 const XML_Char *entityName,
516 int is_parameter_entity);
518 /* This structure is filled in by the XML_UnknownEncodingHandler to
519 provide information to the parser about encodings that are unknown
522 The map[b] member gives information about byte sequences whose
525 If map[b] is c where c is >= 0, then b by itself encodes the
526 Unicode scalar value c.
528 If map[b] is -1, then the byte sequence is malformed.
530 If map[b] is -n, where n >= 2, then b is the first byte of an
531 n-byte sequence that encodes a single Unicode scalar value.
533 The data member will be passed as the first argument to the convert
536 The convert function is used to convert multibyte sequences; s will
537 point to a n-byte sequence where map[(unsigned char)*s] == -n. The
538 convert function must return the Unicode scalar value represented
539 by this byte sequence or -1 if the byte sequence is malformed.
541 The convert function may be NULL if the encoding is a single-byte
542 encoding, that is if map[b] >= -1 for all bytes b.
544 When the parser is finished with the encoding, then if release is
545 not NULL, it will call release passing it the data member; once
546 release has been called, the convert function will not be called
549 Expat places certain restrictions on the encodings that are supported
550 using this mechanism.
552 1. Every ASCII character that can appear in a well-formed XML document,
553 other than the characters
557 must be represented by a single byte, and that byte must be the
558 same byte that represents that character in ASCII.
560 2. No character may require more than 4 bytes to encode.
562 3. All characters encoded must have Unicode scalar values <=
563 0xFFFF, (i.e., characters that would be encoded by surrogates in
564 UTF-16 are not allowed). Note that this restriction doesn't
565 apply to the built-in support for UTF-8 and UTF-16.
567 4. No Unicode character may be encoded by more than one distinct
573 int (XMLCALL *convert)(void *data, const char *s);
574 void (XMLCALL *release)(void *data);
577 /* This is called for an encoding that is unknown to the parser.
579 The encodingHandlerData argument is that which was passed as the
580 second argument to XML_SetUnknownEncodingHandler.
582 The name argument gives the name of the encoding as specified in
583 the encoding declaration.
585 If the callback can provide information about the encoding, it must
586 fill in the XML_Encoding structure, and return XML_STATUS_OK.
587 Otherwise it must return XML_STATUS_ERROR.
589 If info does not describe a suitable encoding, then the parser will
590 return an XML_UNKNOWN_ENCODING error.
592 typedef int (XMLCALL *XML_UnknownEncodingHandler) (
593 void *encodingHandlerData,
594 const XML_Char *name,
598 XML_SetElementHandler(XML_Parser parser,
599 XML_StartElementHandler start,
600 XML_EndElementHandler end);
603 XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
606 XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
609 XML_SetCharacterDataHandler(XML_Parser parser,
610 XML_CharacterDataHandler handler);
613 XML_SetProcessingInstructionHandler(XML_Parser parser,
614 XML_ProcessingInstructionHandler handler);
616 XML_SetCommentHandler(XML_Parser parser,
617 XML_CommentHandler handler);
620 XML_SetCdataSectionHandler(XML_Parser parser,
621 XML_StartCdataSectionHandler start,
622 XML_EndCdataSectionHandler end);
625 XML_SetStartCdataSectionHandler(XML_Parser parser,
626 XML_StartCdataSectionHandler start);
629 XML_SetEndCdataSectionHandler(XML_Parser parser,
630 XML_EndCdataSectionHandler end);
632 /* This sets the default handler and also inhibits expansion of
633 internal entities. These entity references will be passed to the
634 default handler, or to the skipped entity handler, if one is set.
637 XML_SetDefaultHandler(XML_Parser parser,
638 XML_DefaultHandler handler);
640 /* This sets the default handler but does not inhibit expansion of
641 internal entities. The entity reference will not be passed to the
645 XML_SetDefaultHandlerExpand(XML_Parser parser,
646 XML_DefaultHandler handler);
649 XML_SetDoctypeDeclHandler(XML_Parser parser,
650 XML_StartDoctypeDeclHandler start,
651 XML_EndDoctypeDeclHandler end);
654 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
655 XML_StartDoctypeDeclHandler start);
658 XML_SetEndDoctypeDeclHandler(XML_Parser parser,
659 XML_EndDoctypeDeclHandler end);
662 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
663 XML_UnparsedEntityDeclHandler handler);
666 XML_SetNotationDeclHandler(XML_Parser parser,
667 XML_NotationDeclHandler handler);
670 XML_SetNamespaceDeclHandler(XML_Parser parser,
671 XML_StartNamespaceDeclHandler start,
672 XML_EndNamespaceDeclHandler end);
675 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
676 XML_StartNamespaceDeclHandler start);
679 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
680 XML_EndNamespaceDeclHandler end);
683 XML_SetNotStandaloneHandler(XML_Parser parser,
684 XML_NotStandaloneHandler handler);
687 XML_SetExternalEntityRefHandler(XML_Parser parser,
688 XML_ExternalEntityRefHandler handler);
690 /* If a non-NULL value for arg is specified here, then it will be
691 passed as the first argument to the external entity ref handler
692 instead of the parser object.
695 XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
698 XML_SetSkippedEntityHandler(XML_Parser parser,
699 XML_SkippedEntityHandler handler);
702 XML_SetUnknownEncodingHandler(XML_Parser parser,
703 XML_UnknownEncodingHandler handler,
704 void *encodingHandlerData);
706 /* This can be called within a handler for a start element, end
707 element, processing instruction or character data. It causes the
708 corresponding markup to be passed to the default handler.
711 XML_DefaultCurrent(XML_Parser parser);
713 /* If do_nst is non-zero, and namespace processing is in effect, and
714 a name has a prefix (i.e. an explicit namespace qualifier) then
715 that name is returned as a triplet in a single string separated by
716 the separator character specified when the parser was created: URI
717 + sep + local_name + sep + prefix.
719 If do_nst is zero, then namespace information is returned in the
720 default manner (URI + sep + local_name) whether or not the name
723 Note: Calling XML_SetReturnNSTriplet after XML_Parse or
724 XML_ParseBuffer has no effect.
728 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
730 /* This value is passed as the userData argument to callbacks. */
732 XML_SetUserData(XML_Parser parser, void *userData);
734 /* Returns the last value set by XML_SetUserData or NULL. */
735 #define XML_GetUserData(parser) (*(void **)(parser))
737 /* This is equivalent to supplying an encoding argument to
738 XML_ParserCreate. On success XML_SetEncoding returns non-zero,
740 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
741 has no effect and returns XML_STATUS_ERROR.
743 XMLPARSEAPI(enum XML_Status)
744 XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
746 /* If this function is called, then the parser will be passed as the
747 first argument to callbacks instead of userData. The userData will
748 still be accessible using XML_GetUserData.
751 XML_UseParserAsHandlerArg(XML_Parser parser);
753 /* If useDTD == XML_TRUE is passed to this function, then the parser
754 will assume that there is an external subset, even if none is
755 specified in the document. In such a case the parser will call the
756 externalEntityRefHandler with a value of NULL for the systemId
757 argument (the publicId and context arguments will be NULL as well).
758 Note: If this function is called, then this must be done before
759 the first call to XML_Parse or XML_ParseBuffer, since it will
760 have no effect after that. Returns
761 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
762 Note: If the document does not have a DOCTYPE declaration at all,
763 then startDoctypeDeclHandler and endDoctypeDeclHandler will not
764 be called, despite an external subset being parsed.
765 Note: If XML_DTD is not defined when Expat is compiled, returns
766 XML_ERROR_FEATURE_REQUIRES_XML_DTD.
768 XMLPARSEAPI(enum XML_Error)
769 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
772 /* Sets the base to be used for resolving relative URIs in system
773 identifiers in declarations. Resolving relative identifiers is
774 left to the application: this value will be passed through as the
775 base argument to the XML_ExternalEntityRefHandler,
776 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
777 argument will be copied. Returns XML_STATUS_ERROR if out of memory,
778 XML_STATUS_OK otherwise.
780 XMLPARSEAPI(enum XML_Status)
781 XML_SetBase(XML_Parser parser, const XML_Char *base);
783 XMLPARSEAPI(const XML_Char *)
784 XML_GetBase(XML_Parser parser);
786 /* Returns the number of the attribute/value pairs passed in last call
787 to the XML_StartElementHandler that were specified in the start-tag
788 rather than defaulted. Each attribute/value pair counts as 2; thus
789 this correspondds to an index into the atts array passed to the
790 XML_StartElementHandler.
793 XML_GetSpecifiedAttributeCount(XML_Parser parser);
795 /* Returns the index of the ID attribute passed in the last call to
796 XML_StartElementHandler, or -1 if there is no ID attribute. Each
797 attribute/value pair counts as 2; thus this correspondds to an
798 index into the atts array passed to the XML_StartElementHandler.
801 XML_GetIdAttributeIndex(XML_Parser parser);
803 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
804 detected. The last call to XML_Parse must have isFinal true; len
805 may be zero for this call (or any other).
807 Though the return values for these functions has always been
808 described as a Boolean value, the implementation, at least for the
809 1.95.x series, has always returned exactly one of the XML_Status
812 XMLPARSEAPI(enum XML_Status)
813 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
816 XML_GetBuffer(XML_Parser parser, int len);
818 XMLPARSEAPI(enum XML_Status)
819 XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
821 /* Creates an XML_Parser object that can parse an external general
822 entity; context is a '\0'-terminated string specifying the parse
823 context; encoding is a '\0'-terminated string giving the name of
824 the externally specified encoding, or NULL if there is no
825 externally specified encoding. The context string consists of a
826 sequence of tokens separated by formfeeds (\f); a token consisting
827 of a name specifies that the general entity of the name is open; a
828 token of the form prefix=uri specifies the namespace for a
829 particular prefix; a token of the form =uri specifies the default
830 namespace. This can be called at any point after the first call to
831 an ExternalEntityRefHandler so longer as the parser has not yet
832 been freed. The new parser is completely independent and may
833 safely be used in a separate thread. The handlers and userData are
834 initialized from the parser argument. Returns NULL if out of memory.
835 Otherwise returns a new XML_Parser object.
837 XMLPARSEAPI(XML_Parser)
838 XML_ExternalEntityParserCreate(XML_Parser parser,
839 const XML_Char *context,
840 const XML_Char *encoding);
842 enum XML_ParamEntityParsing {
843 XML_PARAM_ENTITY_PARSING_NEVER,
844 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
845 XML_PARAM_ENTITY_PARSING_ALWAYS
848 /* Controls parsing of parameter entities (including the external DTD
849 subset). If parsing of parameter entities is enabled, then
850 references to external parameter entities (including the external
851 DTD subset) will be passed to the handler set with
852 XML_SetExternalEntityRefHandler. The context passed will be 0.
854 Unlike external general entities, external parameter entities can
855 only be parsed synchronously. If the external parameter entity is
856 to be parsed, it must be parsed during the call to the external
857 entity ref handler: the complete sequence of
858 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
859 XML_ParserFree calls must be made during this call. After
860 XML_ExternalEntityParserCreate has been called to create the parser
861 for the external parameter entity (context must be 0 for this
862 call), it is illegal to make any calls on the old parser until
863 XML_ParserFree has been called on the newly created parser.
864 If the library has been compiled without support for parameter
865 entity parsing (ie without XML_DTD being defined), then
866 XML_SetParamEntityParsing will return 0 if parsing of parameter
867 entities is requested; otherwise it will return non-zero.
868 Note: If XML_SetParamEntityParsing is called after XML_Parse or
869 XML_ParseBuffer, then it has no effect and will always return 0.
872 XML_SetParamEntityParsing(XML_Parser parser,
873 enum XML_ParamEntityParsing parsing);
875 /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
876 XML_GetErrorCode returns information about the error.
878 XMLPARSEAPI(enum XML_Error)
879 XML_GetErrorCode(XML_Parser parser);
881 /* These functions return information about the current parse
882 location. They may be called from any callback called to report
883 some parse event; in this case the location is the location of the
884 first of the sequence of characters that generated the event. When
885 called from callbacks generated by declarations in the document
886 prologue, the location identified isn't as neatly defined, but will
887 be within the relevant markup. When called outside of the callback
888 functions, the position indicated will be just past the last parse
889 event (regardless of whether there was an associated callback).
891 They may also be called after returning from a call to XML_Parse
892 or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
893 the location is the location of the character at which the error
894 was detected; otherwise the location is the location of the last
895 parse event, as described above.
897 XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
898 XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
899 XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
901 /* Return the number of bytes in the current event.
902 Returns 0 if the event is in an internal entity.
905 XML_GetCurrentByteCount(XML_Parser parser);
907 /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
908 the integer pointed to by offset to the offset within this buffer
909 of the current parse position, and sets the integer pointed to by size
910 to the size of this buffer (the number of input bytes). Otherwise
911 returns a NULL pointer. Also returns a NULL pointer if a parse isn't
914 NOTE: The character pointer returned should not be used outside
915 the handler that makes the call.
917 XMLPARSEAPI(const char *)
918 XML_GetInputContext(XML_Parser parser,
922 /* For backwards compatibility with previous versions. */
923 #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
924 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
925 #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
927 /* Frees the content model passed to the element declaration handler */
929 XML_FreeContentModel(XML_Parser parser, XML_Content *model);
931 /* Exposing the memory handling functions used in Expat */
933 XML_MemMalloc(XML_Parser parser, size_t size);
936 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
939 XML_MemFree(XML_Parser parser, void *ptr);
941 /* Frees memory used by the parser. */
943 XML_ParserFree(XML_Parser parser);
945 /* Returns a string describing the error. */
946 XMLPARSEAPI(const XML_LChar *)
947 XML_ErrorString(enum XML_Error code);
949 /* Return a string containing the version number of this expat */
950 XMLPARSEAPI(const XML_LChar *)
951 XML_ExpatVersion(void);
959 /* Return an XML_Expat_Version structure containing numeric version
960 number information for this version of expat.
962 XMLPARSEAPI(XML_Expat_Version)
963 XML_ExpatVersionInfo(void);
965 /* Added in Expat 1.95.5. */
966 enum XML_FeatureEnum {
969 XML_FEATURE_UNICODE_WCHAR_T,
971 XML_FEATURE_CONTEXT_BYTES,
972 XML_FEATURE_MIN_SIZE,
973 XML_FEATURE_SIZEOF_XML_CHAR,
974 XML_FEATURE_SIZEOF_XML_LCHAR
975 /* Additional features must be added to the end of this enum. */
979 enum XML_FeatureEnum feature;
980 const XML_LChar *name;
984 XMLPARSEAPI(const XML_Feature *)
985 XML_GetFeatureList(void);
988 /* Expat follows the GNU/Linux convention of odd number minor version for
989 beta/development releases and even number minor version for stable
990 releases. Micro is bumped with each release, and set to 0 with each
991 change to major or minor version.
993 #define XML_MAJOR_VERSION 1
994 #define XML_MINOR_VERSION 95
995 #define XML_MICRO_VERSION 7
1001 #endif /* not XmlParse_INCLUDED */