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)
60 /* The XML_Status enum gives the possible return values for several
61 API functions. The preprocessor #defines are included so this
62 stanza can be added to code that still needs to support older
63 versions of Expat 1.95.x:
66 #define XML_STATUS_OK 1
67 #define XML_STATUS_ERROR 0
70 Otherwise, the #define hackery is quite ugly and would have been
75 #define XML_STATUS_ERROR XML_STATUS_ERROR
77 #define XML_STATUS_OK XML_STATUS_OK
84 XML_ERROR_NO_ELEMENTS,
85 XML_ERROR_INVALID_TOKEN,
86 XML_ERROR_UNCLOSED_TOKEN,
87 XML_ERROR_PARTIAL_CHAR,
88 XML_ERROR_TAG_MISMATCH,
89 XML_ERROR_DUPLICATE_ATTRIBUTE,
90 XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
91 XML_ERROR_PARAM_ENTITY_REF,
92 XML_ERROR_UNDEFINED_ENTITY,
93 XML_ERROR_RECURSIVE_ENTITY_REF,
94 XML_ERROR_ASYNC_ENTITY,
95 XML_ERROR_BAD_CHAR_REF,
96 XML_ERROR_BINARY_ENTITY_REF,
97 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
98 XML_ERROR_MISPLACED_XML_PI,
99 XML_ERROR_UNKNOWN_ENCODING,
100 XML_ERROR_INCORRECT_ENCODING,
101 XML_ERROR_UNCLOSED_CDATA_SECTION,
102 XML_ERROR_EXTERNAL_ENTITY_HANDLING,
103 XML_ERROR_NOT_STANDALONE,
104 XML_ERROR_UNEXPECTED_STATE,
105 XML_ERROR_ENTITY_DECLARED_IN_PE,
106 XML_ERROR_FEATURE_REQUIRES_XML_DTD,
107 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
108 XML_ERROR_UNBOUND_PREFIX
111 enum XML_Content_Type {
120 enum XML_Content_Quant {
127 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
128 XML_CQUANT_NONE, and the other fields will be zero or NULL.
129 If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
130 numchildren will contain number of elements that may be mixed in
131 and children point to an array of XML_Content cells that will be
132 all of XML_CTYPE_NAME type with no quantification.
134 If type == XML_CTYPE_NAME, then the name points to the name, and
135 the numchildren field will be zero and children will be NULL. The
136 quant fields indicates any quantifiers placed on the name.
138 CHOICE and SEQ will have name NULL, the number of children in
139 numchildren and children will point, recursively, to an array
140 of XML_Content cells.
142 The EMPTY, ANY, and MIXED types will only occur at top level.
145 typedef struct XML_cp XML_Content;
148 enum XML_Content_Type type;
149 enum XML_Content_Quant quant;
151 unsigned int numchildren;
152 XML_Content * children;
156 /* This is called for an element declaration. See above for
157 description of the model argument. It's the caller's responsibility
158 to free model when finished with it.
160 typedef void (*XML_ElementDeclHandler) (void *userData,
161 const XML_Char *name,
165 XML_SetElementDeclHandler(XML_Parser parser,
166 XML_ElementDeclHandler eldecl);
168 /* The Attlist declaration handler is called for *each* attribute. So
169 a single Attlist declaration with multiple attributes declared will
170 generate multiple calls to this handler. The "default" parameter
171 may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
172 keyword. The "isrequired" parameter will be true and the default
173 value will be NULL in the case of "#REQUIRED". If "isrequired" is
174 true and default is non-NULL, then this is a "#FIXED" default.
176 typedef void (*XML_AttlistDeclHandler) (void *userData,
177 const XML_Char *elname,
178 const XML_Char *attname,
179 const XML_Char *att_type,
180 const XML_Char *dflt,
184 XML_SetAttlistDeclHandler(XML_Parser parser,
185 XML_AttlistDeclHandler attdecl);
187 /* The XML declaration handler is called for *both* XML declarations
188 and text declarations. The way to distinguish is that the version
189 parameter will be NULL for text declarations. The encoding
190 parameter may be NULL for XML declarations. The standalone
191 parameter will be -1, 0, or 1 indicating respectively that there
192 was no standalone parameter in the declaration, that it was given
193 as no, or that it was given as yes.
195 typedef void (*XML_XmlDeclHandler) (void *userData,
196 const XML_Char *version,
197 const XML_Char *encoding,
201 XML_SetXmlDeclHandler(XML_Parser parser,
202 XML_XmlDeclHandler xmldecl);
206 void *(*malloc_fcn)(size_t size);
207 void *(*realloc_fcn)(void *ptr, size_t size);
208 void (*free_fcn)(void *ptr);
209 } XML_Memory_Handling_Suite;
211 /* Constructs a new parser; encoding is the encoding specified by the
212 external protocol or NULL if there is none specified.
214 XMLPARSEAPI(XML_Parser)
215 XML_ParserCreate(const XML_Char *encoding);
217 /* Constructs a new parser and namespace processor. Element type
218 names and attribute names that belong to a namespace will be
219 expanded; unprefixed attribute names are never expanded; unprefixed
220 element type names are expanded only if there is a default
221 namespace. The expanded name is the concatenation of the namespace
222 URI, the namespace separator character, and the local part of the
223 name. If the namespace separator is '\0' then the namespace URI
224 and the local part will be concatenated without any separator.
225 When a namespace is not declared, the name and prefix will be
226 passed through without expansion.
228 XMLPARSEAPI(XML_Parser)
229 XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
232 /* Constructs a new parser using the memory management suite referred to
233 by memsuite. If memsuite is NULL, then use the standard library memory
234 suite. If namespaceSeparator is non-NULL it creates a parser with
235 namespace processing as described above. The character pointed at
236 will serve as the namespace separator.
238 All further memory operations used for the created parser will come from
241 XMLPARSEAPI(XML_Parser)
242 XML_ParserCreate_MM(const XML_Char *encoding,
243 const XML_Memory_Handling_Suite *memsuite,
244 const XML_Char *namespaceSeparator);
246 /* Prepare a parser object to be re-used. This is particularly
247 valuable when memory allocation overhead is disproportionatly high,
248 such as when a large number of small documnents need to be parsed.
249 All handlers are cleared from the parser, except for the
250 unknownEncodingHandler. The parser's external state is re-initialized
251 except for the values of ns and ns_triplets.
253 Added in Expat 1.95.3.
255 XMLPARSEAPI(XML_Bool)
256 XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
258 /* atts is array of name/value pairs, terminated by 0;
259 names and values are 0 terminated.
261 typedef void (*XML_StartElementHandler)(void *userData,
262 const XML_Char *name,
263 const XML_Char **atts);
265 typedef void (*XML_EndElementHandler)(void *userData,
266 const XML_Char *name);
269 /* s is not 0 terminated. */
270 typedef void (*XML_CharacterDataHandler)(void *userData,
274 /* target and data are 0 terminated */
275 typedef void (*XML_ProcessingInstructionHandler)(void *userData,
276 const XML_Char *target,
277 const XML_Char *data);
279 /* data is 0 terminated */
280 typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
282 typedef void (*XML_StartCdataSectionHandler)(void *userData);
283 typedef void (*XML_EndCdataSectionHandler)(void *userData);
285 /* This is called for any characters in the XML document for which
286 there is no applicable handler. This includes both characters that
287 are part of markup which is of a kind that is not reported
288 (comments, markup declarations), or characters that are part of a
289 construct which could be reported but for which no handler has been
290 supplied. The characters are passed exactly as they were in the XML
291 document except that they will be encoded in UTF-8 or UTF-16.
292 Line boundaries are not normalized. Note that a byte order mark
293 character is not passed to the default handler. There are no
294 guarantees about how characters are divided between calls to the
295 default handler: for example, a comment might be split between
298 typedef void (*XML_DefaultHandler)(void *userData,
302 /* This is called for the start of the DOCTYPE declaration, before
303 any DTD or internal subset is parsed.
305 typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
306 const XML_Char *doctypeName,
307 const XML_Char *sysid,
308 const XML_Char *pubid,
309 int has_internal_subset);
311 /* This is called for the start of the DOCTYPE declaration when the
312 closing > is encountered, but after processing any external
315 typedef void (*XML_EndDoctypeDeclHandler)(void *userData);
317 /* This is called for entity declarations. The is_parameter_entity
318 argument will be non-zero if the entity is a parameter entity, zero
321 For internal entities (<!ENTITY foo "bar">), value will
322 be non-NULL and systemId, publicID, and notationName will be NULL.
323 The value string is NOT nul-terminated; the length is provided in
324 the value_length argument. Since it is legal to have zero-length
325 values, do not use this argument to test for internal entities.
327 For external entities, value will be NULL and systemId will be
328 non-NULL. The publicId argument will be NULL unless a public
329 identifier was provided. The notationName argument will have a
330 non-NULL value only for unparsed entity declarations.
332 Note that is_parameter_entity can't be changed to XML_Bool, since
333 that would break binary compatibility.
335 typedef void (*XML_EntityDeclHandler) (void *userData,
336 const XML_Char *entityName,
337 int is_parameter_entity,
338 const XML_Char *value,
340 const XML_Char *base,
341 const XML_Char *systemId,
342 const XML_Char *publicId,
343 const XML_Char *notationName);
346 XML_SetEntityDeclHandler(XML_Parser parser,
347 XML_EntityDeclHandler handler);
349 /* OBSOLETE -- OBSOLETE -- OBSOLETE
350 This handler has been superceded by the EntityDeclHandler above.
351 It is provided here for backward compatibility.
353 This is called for a declaration of an unparsed (NDATA) entity.
354 The base argument is whatever was set by XML_SetBase. The
355 entityName, systemId and notationName arguments will never be
356 NULL. The other arguments may be.
358 typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
359 const XML_Char *entityName,
360 const XML_Char *base,
361 const XML_Char *systemId,
362 const XML_Char *publicId,
363 const XML_Char *notationName);
365 /* This is called for a declaration of notation. The base argument is
366 whatever was set by XML_SetBase. The notationName will never be
367 NULL. The other arguments can be.
369 typedef void (*XML_NotationDeclHandler)(void *userData,
370 const XML_Char *notationName,
371 const XML_Char *base,
372 const XML_Char *systemId,
373 const XML_Char *publicId);
375 /* When namespace processing is enabled, these are called once for
376 each namespace declaration. The call to the start and end element
377 handlers occur between the calls to the start and end namespace
378 declaration handlers. For an xmlns attribute, prefix will be
379 NULL. For an xmlns="" attribute, uri will be NULL.
381 typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
382 const XML_Char *prefix,
383 const XML_Char *uri);
385 typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
386 const XML_Char *prefix);
388 /* This is called if the document is not standalone, that is, it has an
389 external subset or a reference to a parameter entity, but does not
390 have standalone="yes". If this handler returns XML_STATUS_ERROR,
391 then processing will not continue, and the parser will return a
392 XML_ERROR_NOT_STANDALONE error.
393 If parameter entity parsing is enabled, then in addition to the
394 conditions above this handler will only be called if the referenced
395 entity was actually read.
397 typedef int (*XML_NotStandaloneHandler)(void *userData);
399 /* This is called for a reference to an external parsed general
400 entity. The referenced entity is not automatically parsed. The
401 application can parse it immediately or later using
402 XML_ExternalEntityParserCreate.
404 The parser argument is the parser parsing the entity containing the
405 reference; it can be passed as the parser argument to
406 XML_ExternalEntityParserCreate. The systemId argument is the
407 system identifier as specified in the entity declaration; it will
410 The base argument is the system identifier that should be used as
411 the base for resolving systemId if systemId was relative; this is
412 set by XML_SetBase; it may be NULL.
414 The publicId argument is the public identifier as specified in the
415 entity declaration, or NULL if none was specified; the whitespace
416 in the public identifier will have been normalized as required by
419 The context argument specifies the parsing context in the format
420 expected by the context argument to XML_ExternalEntityParserCreate;
421 context is valid only until the handler returns, so if the
422 referenced entity is to be parsed later, it must be copied.
423 context is NULL only when the entity is a parameter entity.
425 The handler should return XML_STATUS_ERROR if processing should not
426 continue because of a fatal error in the handling of the external
427 entity. In this case the calling parser will return an
428 XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
430 Note that unlike other handlers the first argument is the parser,
433 typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
434 const XML_Char *context,
435 const XML_Char *base,
436 const XML_Char *systemId,
437 const XML_Char *publicId);
439 /* This is called in two situations:
440 1) An entity reference is encountered for which no declaration
441 has been read *and* this is not an error.
442 2) An internal entity reference is read, but not expanded, because
443 XML_SetDefaultHandler has been called.
444 Note: skipped parameter entities in declarations and skipped general
445 entities in attribute values cannot be reported, because
446 the event would be out of sync with the reporting of the
447 declarations or attribute values
449 typedef void (*XML_SkippedEntityHandler)(void *userData,
450 const XML_Char *entityName,
451 int is_parameter_entity);
453 /* This structure is filled in by the XML_UnknownEncodingHandler to
454 provide information to the parser about encodings that are unknown
457 The map[b] member gives information about byte sequences whose
460 If map[b] is c where c is >= 0, then b by itself encodes the
461 Unicode scalar value c.
463 If map[b] is -1, then the byte sequence is malformed.
465 If map[b] is -n, where n >= 2, then b is the first byte of an
466 n-byte sequence that encodes a single Unicode scalar value.
468 The data member will be passed as the first argument to the convert
471 The convert function is used to convert multibyte sequences; s will
472 point to a n-byte sequence where map[(unsigned char)*s] == -n. The
473 convert function must return the Unicode scalar value represented
474 by this byte sequence or -1 if the byte sequence is malformed.
476 The convert function may be NULL if the encoding is a single-byte
477 encoding, that is if map[b] >= -1 for all bytes b.
479 When the parser is finished with the encoding, then if release is
480 not NULL, it will call release passing it the data member; once
481 release has been called, the convert function will not be called
484 Expat places certain restrictions on the encodings that are supported
485 using this mechanism.
487 1. Every ASCII character that can appear in a well-formed XML document,
488 other than the characters
492 must be represented by a single byte, and that byte must be the
493 same byte that represents that character in ASCII.
495 2. No character may require more than 4 bytes to encode.
497 3. All characters encoded must have Unicode scalar values <=
498 0xFFFF, (i.e., characters that would be encoded by surrogates in
499 UTF-16 are not allowed). Note that this restriction doesn't
500 apply to the built-in support for UTF-8 and UTF-16.
502 4. No Unicode character may be encoded by more than one distinct
508 int (*convert)(void *data, const char *s);
509 void (*release)(void *data);
512 /* This is called for an encoding that is unknown to the parser.
514 The encodingHandlerData argument is that which was passed as the
515 second argument to XML_SetUnknownEncodingHandler.
517 The name argument gives the name of the encoding as specified in
518 the encoding declaration.
520 If the callback can provide information about the encoding, it must
521 fill in the XML_Encoding structure, and return XML_STATUS_OK.
522 Otherwise it must return XML_STATUS_ERROR.
524 If info does not describe a suitable encoding, then the parser will
525 return an XML_UNKNOWN_ENCODING error.
527 typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
528 const XML_Char *name,
532 XML_SetElementHandler(XML_Parser parser,
533 XML_StartElementHandler start,
534 XML_EndElementHandler end);
537 XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
540 XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
543 XML_SetCharacterDataHandler(XML_Parser parser,
544 XML_CharacterDataHandler handler);
547 XML_SetProcessingInstructionHandler(XML_Parser parser,
548 XML_ProcessingInstructionHandler handler);
550 XML_SetCommentHandler(XML_Parser parser,
551 XML_CommentHandler handler);
554 XML_SetCdataSectionHandler(XML_Parser parser,
555 XML_StartCdataSectionHandler start,
556 XML_EndCdataSectionHandler end);
559 XML_SetStartCdataSectionHandler(XML_Parser parser,
560 XML_StartCdataSectionHandler start);
563 XML_SetEndCdataSectionHandler(XML_Parser parser,
564 XML_EndCdataSectionHandler end);
566 /* This sets the default handler and also inhibits expansion of
567 internal entities. These entity references will be passed to the
568 default handler, or to the skipped entity handler, if one is set.
571 XML_SetDefaultHandler(XML_Parser parser,
572 XML_DefaultHandler handler);
574 /* This sets the default handler but does not inhibit expansion of
575 internal entities. The entity reference will not be passed to the
579 XML_SetDefaultHandlerExpand(XML_Parser parser,
580 XML_DefaultHandler handler);
583 XML_SetDoctypeDeclHandler(XML_Parser parser,
584 XML_StartDoctypeDeclHandler start,
585 XML_EndDoctypeDeclHandler end);
588 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
589 XML_StartDoctypeDeclHandler start);
592 XML_SetEndDoctypeDeclHandler(XML_Parser parser,
593 XML_EndDoctypeDeclHandler end);
596 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
597 XML_UnparsedEntityDeclHandler handler);
600 XML_SetNotationDeclHandler(XML_Parser parser,
601 XML_NotationDeclHandler handler);
604 XML_SetNamespaceDeclHandler(XML_Parser parser,
605 XML_StartNamespaceDeclHandler start,
606 XML_EndNamespaceDeclHandler end);
609 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
610 XML_StartNamespaceDeclHandler start);
613 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
614 XML_EndNamespaceDeclHandler end);
617 XML_SetNotStandaloneHandler(XML_Parser parser,
618 XML_NotStandaloneHandler handler);
621 XML_SetExternalEntityRefHandler(XML_Parser parser,
622 XML_ExternalEntityRefHandler handler);
624 /* If a non-NULL value for arg is specified here, then it will be
625 passed as the first argument to the external entity ref handler
626 instead of the parser object.
629 XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
632 XML_SetSkippedEntityHandler(XML_Parser parser,
633 XML_SkippedEntityHandler handler);
636 XML_SetUnknownEncodingHandler(XML_Parser parser,
637 XML_UnknownEncodingHandler handler,
638 void *encodingHandlerData);
640 /* This can be called within a handler for a start element, end
641 element, processing instruction or character data. It causes the
642 corresponding markup to be passed to the default handler.
645 XML_DefaultCurrent(XML_Parser parser);
647 /* If do_nst is non-zero, and namespace processing is in effect, and
648 a name has a prefix (i.e. an explicit namespace qualifier) then
649 that name is returned as a triplet in a single string separated by
650 the separator character specified when the parser was created: URI
651 + sep + local_name + sep + prefix.
653 If do_nst is zero, then namespace information is returned in the
654 default manner (URI + sep + local_name) whether or not the name
657 Note: Calling XML_SetReturnNSTriplet after XML_Parse or
658 XML_ParseBuffer has no effect.
662 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
664 /* This value is passed as the userData argument to callbacks. */
666 XML_SetUserData(XML_Parser parser, void *userData);
668 /* Returns the last value set by XML_SetUserData or NULL. */
669 #define XML_GetUserData(parser) (*(void **)(parser))
671 /* This is equivalent to supplying an encoding argument to
672 XML_ParserCreate. On success XML_SetEncoding returns non-zero,
674 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
675 has no effect and returns XML_STATUS_ERROR.
677 XMLPARSEAPI(enum XML_Status)
678 XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
680 /* If this function is called, then the parser will be passed as the
681 first argument to callbacks instead of userData. The userData will
682 still be accessible using XML_GetUserData.
685 XML_UseParserAsHandlerArg(XML_Parser parser);
687 /* If useDTD == XML_TRUE is passed to this function, then the parser
688 will assume that there is an external subset, even if none is
689 specified in the document. In such a case the parser will call the
690 externalEntityRefHandler with a value of NULL for the systemId
691 argument (the publicId and context arguments will be NULL as well).
692 Note: If this function is called, then this must be done before
693 the first call to XML_Parse or XML_ParseBuffer, since it will
694 have no effect after that. Returns
695 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
696 Note: If the document does not have a DOCTYPE declaration at all,
697 then startDoctypeDeclHandler and endDoctypeDeclHandler will not
698 be called, despite an external subset being parsed.
699 Note: If XML_DTD is not defined when Expat is compiled, returns
700 XML_ERROR_FEATURE_REQUIRES_XML_DTD.
702 XMLPARSEAPI(enum XML_Error)
703 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
706 /* Sets the base to be used for resolving relative URIs in system
707 identifiers in declarations. Resolving relative identifiers is
708 left to the application: this value will be passed through as the
709 base argument to the XML_ExternalEntityRefHandler,
710 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
711 argument will be copied. Returns XML_STATUS_ERROR if out of memory,
712 XML_STATUS_OK otherwise.
714 XMLPARSEAPI(enum XML_Status)
715 XML_SetBase(XML_Parser parser, const XML_Char *base);
717 XMLPARSEAPI(const XML_Char *)
718 XML_GetBase(XML_Parser parser);
720 /* Returns the number of the attribute/value pairs passed in last call
721 to the XML_StartElementHandler that were specified in the start-tag
722 rather than defaulted. Each attribute/value pair counts as 2; thus
723 this correspondds to an index into the atts array passed to the
724 XML_StartElementHandler.
727 XML_GetSpecifiedAttributeCount(XML_Parser parser);
729 /* Returns the index of the ID attribute passed in the last call to
730 XML_StartElementHandler, or -1 if there is no ID attribute. Each
731 attribute/value pair counts as 2; thus this correspondds to an
732 index into the atts array passed to the XML_StartElementHandler.
735 XML_GetIdAttributeIndex(XML_Parser parser);
737 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
738 detected. The last call to XML_Parse must have isFinal true; len
739 may be zero for this call (or any other).
741 Though the return values for these functions has always been
742 described as a Boolean value, the implementation, at least for the
743 1.95.x series, has always returned exactly one of the XML_Status
746 XMLPARSEAPI(enum XML_Status)
747 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
750 XML_GetBuffer(XML_Parser parser, int len);
752 XMLPARSEAPI(enum XML_Status)
753 XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
755 /* Creates an XML_Parser object that can parse an external general
756 entity; context is a '\0'-terminated string specifying the parse
757 context; encoding is a '\0'-terminated string giving the name of
758 the externally specified encoding, or NULL if there is no
759 externally specified encoding. The context string consists of a
760 sequence of tokens separated by formfeeds (\f); a token consisting
761 of a name specifies that the general entity of the name is open; a
762 token of the form prefix=uri specifies the namespace for a
763 particular prefix; a token of the form =uri specifies the default
764 namespace. This can be called at any point after the first call to
765 an ExternalEntityRefHandler so longer as the parser has not yet
766 been freed. The new parser is completely independent and may
767 safely be used in a separate thread. The handlers and userData are
768 initialized from the parser argument. Returns NULL if out of memory.
769 Otherwise returns a new XML_Parser object.
771 XMLPARSEAPI(XML_Parser)
772 XML_ExternalEntityParserCreate(XML_Parser parser,
773 const XML_Char *context,
774 const XML_Char *encoding);
776 enum XML_ParamEntityParsing {
777 XML_PARAM_ENTITY_PARSING_NEVER,
778 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
779 XML_PARAM_ENTITY_PARSING_ALWAYS
782 /* Controls parsing of parameter entities (including the external DTD
783 subset). If parsing of parameter entities is enabled, then
784 references to external parameter entities (including the external
785 DTD subset) will be passed to the handler set with
786 XML_SetExternalEntityRefHandler. The context passed will be 0.
788 Unlike external general entities, external parameter entities can
789 only be parsed synchronously. If the external parameter entity is
790 to be parsed, it must be parsed during the call to the external
791 entity ref handler: the complete sequence of
792 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
793 XML_ParserFree calls must be made during this call. After
794 XML_ExternalEntityParserCreate has been called to create the parser
795 for the external parameter entity (context must be 0 for this
796 call), it is illegal to make any calls on the old parser until
797 XML_ParserFree has been called on the newly created parser.
798 If the library has been compiled without support for parameter
799 entity parsing (ie without XML_DTD being defined), then
800 XML_SetParamEntityParsing will return 0 if parsing of parameter
801 entities is requested; otherwise it will return non-zero.
802 Note: If XML_SetParamEntityParsing is called after XML_Parse or
803 XML_ParseBuffer, then it has no effect and will always return 0.
806 XML_SetParamEntityParsing(XML_Parser parser,
807 enum XML_ParamEntityParsing parsing);
809 /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
810 XML_GetErrorCode returns information about the error.
812 XMLPARSEAPI(enum XML_Error)
813 XML_GetErrorCode(XML_Parser parser);
815 /* These functions return information about the current parse
816 location. They may be called from any callback called to report
817 some parse event; in this case the location is the location of the
818 first of the sequence of characters that generated the event. When
819 called from callbacks generated by declarations in the document
820 prologue, the location identified isn't as neatly defined, but will
821 be within the relevant markup. When called outside of the callback
822 functions, the position indicated will be just past the last parse
823 event (regardless of whether there was an associated callback).
825 They may also be called after returning from a call to XML_Parse
826 or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
827 the location is the location of the character at which the error
828 was detected; otherwise the location is the location of the last
829 parse event, as described above.
831 XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
832 XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
833 XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
835 /* Return the number of bytes in the current event.
836 Returns 0 if the event is in an internal entity.
839 XML_GetCurrentByteCount(XML_Parser parser);
841 /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
842 the integer pointed to by offset to the offset within this buffer
843 of the current parse position, and sets the integer pointed to by size
844 to the size of this buffer (the number of input bytes). Otherwise
845 returns a NULL pointer. Also returns a NULL pointer if a parse isn't
848 NOTE: The character pointer returned should not be used outside
849 the handler that makes the call.
851 XMLPARSEAPI(const char *)
852 XML_GetInputContext(XML_Parser parser,
856 /* For backwards compatibility with previous versions. */
857 #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
858 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
859 #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
861 /* Frees the content model passed to the element declaration handler */
863 XML_FreeContentModel(XML_Parser parser, XML_Content *model);
865 /* Exposing the memory handling functions used in Expat */
867 XML_MemMalloc(XML_Parser parser, size_t size);
870 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
873 XML_MemFree(XML_Parser parser, void *ptr);
875 /* Frees memory used by the parser. */
877 XML_ParserFree(XML_Parser parser);
879 /* Returns a string describing the error. */
880 XMLPARSEAPI(const XML_LChar *)
881 XML_ErrorString(enum XML_Error code);
883 /* Return a string containing the version number of this expat */
884 XMLPARSEAPI(const XML_LChar *)
885 XML_ExpatVersion(void);
893 /* Return an XML_Expat_Version structure containing numeric version
894 number information for this version of expat.
896 XMLPARSEAPI(XML_Expat_Version)
897 XML_ExpatVersionInfo(void);
899 /* Added in Expat 1.95.5. */
900 enum XML_FeatureEnum {
903 XML_FEATURE_UNICODE_WCHAR_T,
905 XML_FEATURE_CONTEXT_BYTES,
906 XML_FEATURE_MIN_SIZE,
907 XML_FEATURE_SIZEOF_XML_CHAR,
908 XML_FEATURE_SIZEOF_XML_LCHAR
909 /* Additional features must be added to the end of this enum. */
913 enum XML_FeatureEnum feature;
914 const XML_LChar *name;
918 XMLPARSEAPI(const XML_Feature *)
919 XML_GetFeatureList(void);
922 /* Expat follows the GNU/Linux convention of odd number minor version for
923 beta/development releases and even number minor version for stable
924 releases. Micro is bumped with each release, and set to 0 with each
925 change to major or minor version.
927 #define XML_MAJOR_VERSION 1
928 #define XML_MINOR_VERSION 95
929 #define XML_MICRO_VERSION 6
935 #endif /* not XmlParse_INCLUDED */