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 #define XMLPARSEAPI(type) type
21 #endif /* not defined XMLPARSEAPI */
27 #ifdef XML_UNICODE_WCHAR_T
31 struct XML_ParserStruct
;
32 typedef struct XML_ParserStruct
*XML_Parser
;
34 #ifdef XML_UNICODE /* Information is UTF-16 encoded. */
35 #ifdef XML_UNICODE_WCHAR_T
36 typedef wchar_t XML_Char
;
37 typedef wchar_t XML_LChar
;
39 typedef unsigned short XML_Char
;
40 typedef char XML_LChar
;
41 #endif /* XML_UNICODE_WCHAR_T */
42 #else /* Information is UTF-8 encoded. */
43 typedef char XML_Char
;
44 typedef char XML_LChar
;
45 #endif /* XML_UNICODE */
47 /* Should this be defined using stdbool.h when C99 is available? */
48 typedef unsigned char XML_Bool
;
49 #define XML_TRUE ((XML_Bool) 1)
50 #define XML_FALSE ((XML_Bool) 0)
56 XML_ERROR_NO_ELEMENTS
,
57 XML_ERROR_INVALID_TOKEN
,
58 XML_ERROR_UNCLOSED_TOKEN
,
59 XML_ERROR_PARTIAL_CHAR
,
60 XML_ERROR_TAG_MISMATCH
,
61 XML_ERROR_DUPLICATE_ATTRIBUTE
,
62 XML_ERROR_JUNK_AFTER_DOC_ELEMENT
,
63 XML_ERROR_PARAM_ENTITY_REF
,
64 XML_ERROR_UNDEFINED_ENTITY
,
65 XML_ERROR_RECURSIVE_ENTITY_REF
,
66 XML_ERROR_ASYNC_ENTITY
,
67 XML_ERROR_BAD_CHAR_REF
,
68 XML_ERROR_BINARY_ENTITY_REF
,
69 XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF
,
70 XML_ERROR_MISPLACED_XML_PI
,
71 XML_ERROR_UNKNOWN_ENCODING
,
72 XML_ERROR_INCORRECT_ENCODING
,
73 XML_ERROR_UNCLOSED_CDATA_SECTION
,
74 XML_ERROR_EXTERNAL_ENTITY_HANDLING
,
75 XML_ERROR_NOT_STANDALONE
,
76 XML_ERROR_UNEXPECTED_STATE
,
77 XML_ERROR_ENTITY_DECLARED_IN_PE
,
78 XML_ERROR_FEATURE_REQUIRES_XML_DTD
,
79 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
82 enum XML_Content_Type
{
91 enum XML_Content_Quant
{
98 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
99 detected. The last call to XML_Parse must have isFinal true; len
100 may be zero for this call (or any other).
102 The XML_Status enum gives the possible return values for the
103 XML_Parse and XML_ParseBuffer functions. Though the return values
104 for these functions has always been described as a Boolean value,
105 the implementation, at least for the 1.95.x series, has always
106 returned exactly one of these values. The preprocessor #defines
107 are included so this stanza can be added to code that still needs
108 to support older versions of Expat 1.95.x:
110 #ifndef XML_STATUS_OK
111 #define XML_STATUS_OK 1
112 #define XML_STATUS_ERROR 0
115 Otherwise, the #define hackery is quite ugly and would have been dropped.
118 XML_STATUS_ERROR
= 0,
119 #define XML_STATUS_ERROR XML_STATUS_ERROR
121 #define XML_STATUS_OK XML_STATUS_OK
124 /* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be
125 XML_CQUANT_NONE, and the other fields will be zero or NULL.
126 If type == XML_CTYPE_MIXED, then quant will be NONE or REP and
127 numchildren will contain number of elements that may be mixed in
128 and children point to an array of XML_Content cells that will be
129 all of XML_CTYPE_NAME type with no quantification.
131 If type == XML_CTYPE_NAME, then the name points to the name, and
132 the numchildren field will be zero and children will be NULL. The
133 quant fields indicates any quantifiers placed on the name.
135 CHOICE and SEQ will have name NULL, the number of children in
136 numchildren and children will point, recursively, to an array
137 of XML_Content cells.
139 The EMPTY, ANY, and MIXED types will only occur at top level.
142 typedef struct XML_cp XML_Content
;
145 enum XML_Content_Type type
;
146 enum XML_Content_Quant quant
;
148 unsigned int numchildren
;
149 XML_Content
* children
;
153 /* This is called for an element declaration. See above for
154 description of the model argument. It's the caller's responsibility
155 to free model when finished with it.
157 typedef void (*XML_ElementDeclHandler
) (void *userData
,
158 const XML_Char
*name
,
162 XML_SetElementDeclHandler(XML_Parser parser
,
163 XML_ElementDeclHandler eldecl
);
165 /* The Attlist declaration handler is called for *each* attribute. So
166 a single Attlist declaration with multiple attributes declared will
167 generate multiple calls to this handler. The "default" parameter
168 may be NULL in the case of the "#IMPLIED" or "#REQUIRED"
169 keyword. The "isrequired" parameter will be true and the default
170 value will be NULL in the case of "#REQUIRED". If "isrequired" is
171 true and default is non-NULL, then this is a "#FIXED" default.
173 typedef void (*XML_AttlistDeclHandler
) (void *userData
,
174 const XML_Char
*elname
,
175 const XML_Char
*attname
,
176 const XML_Char
*att_type
,
177 const XML_Char
*dflt
,
181 XML_SetAttlistDeclHandler(XML_Parser parser
,
182 XML_AttlistDeclHandler attdecl
);
184 /* The XML declaration handler is called for *both* XML declarations
185 and text declarations. The way to distinguish is that the version
186 parameter will be NULL for text declarations. The encoding
187 parameter may be NULL for XML declarations. The standalone
188 parameter will be -1, 0, or 1 indicating respectively that there
189 was no standalone parameter in the declaration, that it was given
190 as no, or that it was given as yes.
192 typedef void (*XML_XmlDeclHandler
) (void *userData
,
193 const XML_Char
*version
,
194 const XML_Char
*encoding
,
198 XML_SetXmlDeclHandler(XML_Parser parser
,
199 XML_XmlDeclHandler xmldecl
);
203 void *(*malloc_fcn
)(size_t size
);
204 void *(*realloc_fcn
)(void *ptr
, size_t size
);
205 void (*free_fcn
)(void *ptr
);
206 } XML_Memory_Handling_Suite
;
208 /* Constructs a new parser; encoding is the encoding specified by the
209 external protocol or NULL if there is none specified.
211 XMLPARSEAPI(XML_Parser
)
212 XML_ParserCreate(const XML_Char
*encoding
);
214 /* Constructs a new parser and namespace processor. Element type
215 names and attribute names that belong to a namespace will be
216 expanded; unprefixed attribute names are never expanded; unprefixed
217 element type names are expanded only if there is a default
218 namespace. The expanded name is the concatenation of the namespace
219 URI, the namespace separator character, and the local part of the
220 name. If the namespace separator is '\0' then the namespace URI
221 and the local part will be concatenated without any separator.
222 When a namespace is not declared, the name and prefix will be
223 passed through without expansion.
225 XMLPARSEAPI(XML_Parser
)
226 XML_ParserCreateNS(const XML_Char
*encoding
, XML_Char namespaceSeparator
);
229 /* Constructs a new parser using the memory management suite referred to
230 by memsuite. If memsuite is NULL, then use the standard library memory
231 suite. If namespaceSeparator is non-NULL it creates a parser with
232 namespace processing as described above. The character pointed at
233 will serve as the namespace separator.
235 All further memory operations used for the created parser will come from
238 XMLPARSEAPI(XML_Parser
)
239 XML_ParserCreate_MM(const XML_Char
*encoding
,
240 const XML_Memory_Handling_Suite
*memsuite
,
241 const XML_Char
*namespaceSeparator
);
243 /* Prepare a parser object to be re-used. This is particularly
244 valuable when memory allocation overhead is disproportionatly high,
245 such as when a large number of small documnents need to be parsed.
246 All handlers are cleared from the parser, except for the
247 unknownEncodingHandler. The parser's external state is re-initialized
248 except for the values of ns and ns_triplets.
250 Added in Expat 1.95.3.
252 XMLPARSEAPI(XML_Bool
)
253 XML_ParserReset(XML_Parser parser
, const XML_Char
*encoding
);
255 /* atts is array of name/value pairs, terminated by 0;
256 names and values are 0 terminated.
258 typedef void (*XML_StartElementHandler
)(void *userData
,
259 const XML_Char
*name
,
260 const XML_Char
**atts
);
262 typedef void (*XML_EndElementHandler
)(void *userData
,
263 const XML_Char
*name
);
266 /* s is not 0 terminated. */
267 typedef void (*XML_CharacterDataHandler
)(void *userData
,
271 /* target and data are 0 terminated */
272 typedef void (*XML_ProcessingInstructionHandler
)(void *userData
,
273 const XML_Char
*target
,
274 const XML_Char
*data
);
276 /* data is 0 terminated */
277 typedef void (*XML_CommentHandler
)(void *userData
, const XML_Char
*data
);
279 typedef void (*XML_StartCdataSectionHandler
)(void *userData
);
280 typedef void (*XML_EndCdataSectionHandler
)(void *userData
);
282 /* This is called for any characters in the XML document for which
283 there is no applicable handler. This includes both characters that
284 are part of markup which is of a kind that is not reported
285 (comments, markup declarations), or characters that are part of a
286 construct which could be reported but for which no handler has been
287 supplied. The characters are passed exactly as they were in the XML
288 document except that they will be encoded in UTF-8 or UTF-16.
289 Line boundaries are not normalized. Note that a byte order mark
290 character is not passed to the default handler. There are no
291 guarantees about how characters are divided between calls to the
292 default handler: for example, a comment might be split between
295 typedef void (*XML_DefaultHandler
)(void *userData
,
299 /* This is called for the start of the DOCTYPE declaration, before
300 any DTD or internal subset is parsed.
302 typedef void (*XML_StartDoctypeDeclHandler
)(void *userData
,
303 const XML_Char
*doctypeName
,
304 const XML_Char
*sysid
,
305 const XML_Char
*pubid
,
306 int has_internal_subset
);
308 /* This is called for the start of the DOCTYPE declaration when the
309 closing > is encountered, but after processing any external
312 typedef void (*XML_EndDoctypeDeclHandler
)(void *userData
);
314 /* This is called for entity declarations. The is_parameter_entity
315 argument will be non-zero if the entity is a parameter entity, zero
318 For internal entities (<!ENTITY foo "bar">), value will
319 be non-NULL and systemId, publicID, and notationName will be NULL.
320 The value string is NOT nul-terminated; the length is provided in
321 the value_length argument. Since it is legal to have zero-length
322 values, do not use this argument to test for internal entities.
324 For external entities, value will be NULL and systemId will be
325 non-NULL. The publicId argument will be NULL unless a public
326 identifier was provided. The notationName argument will have a
327 non-NULL value only for unparsed entity declarations.
329 Note that is_parameter_entity can't be changed to XML_Bool, since
330 that would break binary compatibility.
332 typedef void (*XML_EntityDeclHandler
) (void *userData
,
333 const XML_Char
*entityName
,
334 int is_parameter_entity
,
335 const XML_Char
*value
,
337 const XML_Char
*base
,
338 const XML_Char
*systemId
,
339 const XML_Char
*publicId
,
340 const XML_Char
*notationName
);
343 XML_SetEntityDeclHandler(XML_Parser parser
,
344 XML_EntityDeclHandler handler
);
346 /* OBSOLETE -- OBSOLETE -- OBSOLETE
347 This handler has been superceded by the EntityDeclHandler above.
348 It is provided here for backward compatibility.
350 This is called for a declaration of an unparsed (NDATA) entity.
351 The base argument is whatever was set by XML_SetBase. The
352 entityName, systemId and notationName arguments will never be
353 NULL. The other arguments may be.
355 typedef void (*XML_UnparsedEntityDeclHandler
)(void *userData
,
356 const XML_Char
*entityName
,
357 const XML_Char
*base
,
358 const XML_Char
*systemId
,
359 const XML_Char
*publicId
,
360 const XML_Char
*notationName
);
362 /* This is called for a declaration of notation. The base argument is
363 whatever was set by XML_SetBase. The notationName will never be
364 NULL. The other arguments can be.
366 typedef void (*XML_NotationDeclHandler
)(void *userData
,
367 const XML_Char
*notationName
,
368 const XML_Char
*base
,
369 const XML_Char
*systemId
,
370 const XML_Char
*publicId
);
372 /* When namespace processing is enabled, these are called once for
373 each namespace declaration. The call to the start and end element
374 handlers occur between the calls to the start and end namespace
375 declaration handlers. For an xmlns attribute, prefix will be
376 NULL. For an xmlns="" attribute, uri will be NULL.
378 typedef void (*XML_StartNamespaceDeclHandler
)(void *userData
,
379 const XML_Char
*prefix
,
380 const XML_Char
*uri
);
382 typedef void (*XML_EndNamespaceDeclHandler
)(void *userData
,
383 const XML_Char
*prefix
);
385 /* This is called if the document is not standalone, that is, it has an
386 external subset or a reference to a parameter entity, but does not
387 have standalone="yes". If this handler returns XML_STATUS_ERROR,
388 then processing will not continue, and the parser will return a
389 XML_ERROR_NOT_STANDALONE error.
390 If parameter entity parsing is enabled, then in addition to the
391 conditions above this handler will only be called if the referenced
392 entity was actually read.
394 typedef int (*XML_NotStandaloneHandler
)(void *userData
);
396 /* This is called for a reference to an external parsed general
397 entity. The referenced entity is not automatically parsed. The
398 application can parse it immediately or later using
399 XML_ExternalEntityParserCreate.
401 The parser argument is the parser parsing the entity containing the
402 reference; it can be passed as the parser argument to
403 XML_ExternalEntityParserCreate. The systemId argument is the
404 system identifier as specified in the entity declaration; it will
407 The base argument is the system identifier that should be used as
408 the base for resolving systemId if systemId was relative; this is
409 set by XML_SetBase; it may be NULL.
411 The publicId argument is the public identifier as specified in the
412 entity declaration, or NULL if none was specified; the whitespace
413 in the public identifier will have been normalized as required by
416 The context argument specifies the parsing context in the format
417 expected by the context argument to XML_ExternalEntityParserCreate;
418 context is valid only until the handler returns, so if the
419 referenced entity is to be parsed later, it must be copied.
420 context is NULL only when the entity is a parameter entity.
422 The handler should return XML_STATUS_ERROR if processing should not
423 continue because of a fatal error in the handling of the external
424 entity. In this case the calling parser will return an
425 XML_ERROR_EXTERNAL_ENTITY_HANDLING error.
427 Note that unlike other handlers the first argument is the parser,
430 typedef int (*XML_ExternalEntityRefHandler
)(XML_Parser parser
,
431 const XML_Char
*context
,
432 const XML_Char
*base
,
433 const XML_Char
*systemId
,
434 const XML_Char
*publicId
);
436 /* This is called in two situations:
437 1) An entity reference is encountered for which no declaration
438 has been read *and* this is not an error.
439 2) An internal entity reference is read, but not expanded, because
440 XML_SetDefaultHandler has been called.
441 Note: skipped parameter entities in declarations and skipped general
442 entities in attribute values cannot be reported, because
443 the event would be out of sync with the reporting of the
444 declarations or attribute values
446 typedef void (*XML_SkippedEntityHandler
)(void *userData
,
447 const XML_Char
*entityName
,
448 int is_parameter_entity
);
450 /* This structure is filled in by the XML_UnknownEncodingHandler to
451 provide information to the parser about encodings that are unknown
454 The map[b] member gives information about byte sequences whose
457 If map[b] is c where c is >= 0, then b by itself encodes the
458 Unicode scalar value c.
460 If map[b] is -1, then the byte sequence is malformed.
462 If map[b] is -n, where n >= 2, then b is the first byte of an
463 n-byte sequence that encodes a single Unicode scalar value.
465 The data member will be passed as the first argument to the convert
468 The convert function is used to convert multibyte sequences; s will
469 point to a n-byte sequence where map[(unsigned char)*s] == -n. The
470 convert function must return the Unicode scalar value represented
471 by this byte sequence or -1 if the byte sequence is malformed.
473 The convert function may be NULL if the encoding is a single-byte
474 encoding, that is if map[b] >= -1 for all bytes b.
476 When the parser is finished with the encoding, then if release is
477 not NULL, it will call release passing it the data member; once
478 release has been called, the convert function will not be called
481 Expat places certain restrictions on the encodings that are supported
482 using this mechanism.
484 1. Every ASCII character that can appear in a well-formed XML document,
485 other than the characters
489 must be represented by a single byte, and that byte must be the
490 same byte that represents that character in ASCII.
492 2. No character may require more than 4 bytes to encode.
494 3. All characters encoded must have Unicode scalar values <=
495 0xFFFF, (i.e., characters that would be encoded by surrogates in
496 UTF-16 are not allowed). Note that this restriction doesn't
497 apply to the built-in support for UTF-8 and UTF-16.
499 4. No Unicode character may be encoded by more than one distinct
505 int (*convert
)(void *data
, const char *s
);
506 void (*release
)(void *data
);
509 /* This is called for an encoding that is unknown to the parser.
511 The encodingHandlerData argument is that which was passed as the
512 second argument to XML_SetUnknownEncodingHandler.
514 The name argument gives the name of the encoding as specified in
515 the encoding declaration.
517 If the callback can provide information about the encoding, it must
518 fill in the XML_Encoding structure, and return XML_STATUS_OK.
519 Otherwise it must return XML_STATUS_ERROR.
521 If info does not describe a suitable encoding, then the parser will
522 return an XML_UNKNOWN_ENCODING error.
524 typedef int (*XML_UnknownEncodingHandler
)(void *encodingHandlerData
,
525 const XML_Char
*name
,
529 XML_SetElementHandler(XML_Parser parser
,
530 XML_StartElementHandler start
,
531 XML_EndElementHandler end
);
534 XML_SetStartElementHandler(XML_Parser
, XML_StartElementHandler
);
537 XML_SetEndElementHandler(XML_Parser
, XML_EndElementHandler
);
540 XML_SetCharacterDataHandler(XML_Parser parser
,
541 XML_CharacterDataHandler handler
);
544 XML_SetProcessingInstructionHandler(XML_Parser parser
,
545 XML_ProcessingInstructionHandler handler
);
547 XML_SetCommentHandler(XML_Parser parser
,
548 XML_CommentHandler handler
);
551 XML_SetCdataSectionHandler(XML_Parser parser
,
552 XML_StartCdataSectionHandler start
,
553 XML_EndCdataSectionHandler end
);
556 XML_SetStartCdataSectionHandler(XML_Parser parser
,
557 XML_StartCdataSectionHandler start
);
560 XML_SetEndCdataSectionHandler(XML_Parser parser
,
561 XML_EndCdataSectionHandler end
);
563 /* This sets the default handler and also inhibits expansion of
564 internal entities. These entity references will be passed to the
565 default handler, or to the skipped entity handler, if one is set.
568 XML_SetDefaultHandler(XML_Parser parser
,
569 XML_DefaultHandler handler
);
571 /* This sets the default handler but does not inhibit expansion of
572 internal entities. The entity reference will not be passed to the
576 XML_SetDefaultHandlerExpand(XML_Parser parser
,
577 XML_DefaultHandler handler
);
580 XML_SetDoctypeDeclHandler(XML_Parser parser
,
581 XML_StartDoctypeDeclHandler start
,
582 XML_EndDoctypeDeclHandler end
);
585 XML_SetStartDoctypeDeclHandler(XML_Parser parser
,
586 XML_StartDoctypeDeclHandler start
);
589 XML_SetEndDoctypeDeclHandler(XML_Parser parser
,
590 XML_EndDoctypeDeclHandler end
);
593 XML_SetUnparsedEntityDeclHandler(XML_Parser parser
,
594 XML_UnparsedEntityDeclHandler handler
);
597 XML_SetNotationDeclHandler(XML_Parser parser
,
598 XML_NotationDeclHandler handler
);
601 XML_SetNamespaceDeclHandler(XML_Parser parser
,
602 XML_StartNamespaceDeclHandler start
,
603 XML_EndNamespaceDeclHandler end
);
606 XML_SetStartNamespaceDeclHandler(XML_Parser parser
,
607 XML_StartNamespaceDeclHandler start
);
610 XML_SetEndNamespaceDeclHandler(XML_Parser parser
,
611 XML_EndNamespaceDeclHandler end
);
614 XML_SetNotStandaloneHandler(XML_Parser parser
,
615 XML_NotStandaloneHandler handler
);
618 XML_SetExternalEntityRefHandler(XML_Parser parser
,
619 XML_ExternalEntityRefHandler handler
);
621 /* If a non-NULL value for arg is specified here, then it will be
622 passed as the first argument to the external entity ref handler
623 instead of the parser object.
626 XML_SetExternalEntityRefHandlerArg(XML_Parser
, void *arg
);
629 XML_SetSkippedEntityHandler(XML_Parser parser
,
630 XML_SkippedEntityHandler handler
);
633 XML_SetUnknownEncodingHandler(XML_Parser parser
,
634 XML_UnknownEncodingHandler handler
,
635 void *encodingHandlerData
);
637 /* This can be called within a handler for a start element, end
638 element, processing instruction or character data. It causes the
639 corresponding markup to be passed to the default handler.
642 XML_DefaultCurrent(XML_Parser parser
);
644 /* If do_nst is non-zero, and namespace processing is in effect, and
645 a name has a prefix (i.e. an explicit namespace qualifier) then
646 that name is returned as a triplet in a single string separated by
647 the separator character specified when the parser was created: URI
648 + sep + local_name + sep + prefix.
650 If do_nst is zero, then namespace information is returned in the
651 default manner (URI + sep + local_name) whether or not the name
654 Note: Calling XML_SetReturnNSTriplet after XML_Parse or
655 XML_ParseBuffer has no effect.
659 XML_SetReturnNSTriplet(XML_Parser parser
, int do_nst
);
661 /* This value is passed as the userData argument to callbacks. */
663 XML_SetUserData(XML_Parser parser
, void *userData
);
665 /* Returns the last value set by XML_SetUserData or NULL. */
666 #define XML_GetUserData(parser) (*(void **)(parser))
668 /* This is equivalent to supplying an encoding argument to
669 XML_ParserCreate. On success XML_SetEncoding returns non-zero,
671 Note: Calling XML_SetEncoding after XML_Parse or XML_ParseBuffer
672 has no effect and returns XML_STATUS_ERROR.
674 XMLPARSEAPI(enum XML_Status
)
675 XML_SetEncoding(XML_Parser parser
, const XML_Char
*encoding
);
677 /* If this function is called, then the parser will be passed as the
678 first argument to callbacks instead of userData. The userData will
679 still be accessible using XML_GetUserData.
682 XML_UseParserAsHandlerArg(XML_Parser parser
);
684 /* If useDTD == XML_TRUE is passed to this function, then the parser
685 will assume that there is an external subset, even if none is
686 specified in the document. In such a case the parser will call the
687 externalEntityRefHandler with a value of NULL for the systemId
688 argument (the publicId and context arguments will be NULL as well).
689 Note: If this function is called, then this must be done before
690 the first call to XML_Parse or XML_ParseBuffer, since it will
691 have no effect after that. Returns
692 XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING.
693 Note: If the document does not have a DOCTYPE declaration at all,
694 then startDoctypeDeclHandler and endDoctypeDeclHandler will not
695 be called, despite an external subset being parsed.
696 Note: If XML_DTD is not defined when Expat is compiled, returns
697 XML_ERROR_FEATURE_REQUIRES_XML_DTD.
699 XMLPARSEAPI(enum XML_Error
)
700 XML_UseForeignDTD(XML_Parser parser
, XML_Bool useDTD
);
703 /* Sets the base to be used for resolving relative URIs in system
704 identifiers in declarations. Resolving relative identifiers is
705 left to the application: this value will be passed through as the
706 base argument to the XML_ExternalEntityRefHandler,
707 XML_NotationDeclHandler and XML_UnparsedEntityDeclHandler. The base
708 argument will be copied. Returns XML_STATUS_ERROR if out of memory,
709 XML_STATUS_OK otherwise.
711 XMLPARSEAPI(enum XML_Status
)
712 XML_SetBase(XML_Parser parser
, const XML_Char
*base
);
714 XMLPARSEAPI(const XML_Char
*)
715 XML_GetBase(XML_Parser parser
);
717 /* Returns the number of the attribute/value pairs passed in last call
718 to the XML_StartElementHandler that were specified in the start-tag
719 rather than defaulted. Each attribute/value pair counts as 2; thus
720 this correspondds to an index into the atts array passed to the
721 XML_StartElementHandler.
724 XML_GetSpecifiedAttributeCount(XML_Parser parser
);
726 /* Returns the index of the ID attribute passed in the last call to
727 XML_StartElementHandler, or -1 if there is no ID attribute. Each
728 attribute/value pair counts as 2; thus this correspondds to an
729 index into the atts array passed to the XML_StartElementHandler.
732 XML_GetIdAttributeIndex(XML_Parser parser
);
734 XMLPARSEAPI(enum XML_Status
)
735 XML_Parse(XML_Parser parser
, const char *s
, int len
, int isFinal
);
738 XML_GetBuffer(XML_Parser parser
, int len
);
740 XMLPARSEAPI(enum XML_Status
)
741 XML_ParseBuffer(XML_Parser parser
, int len
, int isFinal
);
743 /* Creates an XML_Parser object that can parse an external general
744 entity; context is a '\0'-terminated string specifying the parse
745 context; encoding is a '\0'-terminated string giving the name of
746 the externally specified encoding, or NULL if there is no
747 externally specified encoding. The context string consists of a
748 sequence of tokens separated by formfeeds (\f); a token consisting
749 of a name specifies that the general entity of the name is open; a
750 token of the form prefix=uri specifies the namespace for a
751 particular prefix; a token of the form =uri specifies the default
752 namespace. This can be called at any point after the first call to
753 an ExternalEntityRefHandler so longer as the parser has not yet
754 been freed. The new parser is completely independent and may
755 safely be used in a separate thread. The handlers and userData are
756 initialized from the parser argument. Returns NULL if out of memory.
757 Otherwise returns a new XML_Parser object.
759 XMLPARSEAPI(XML_Parser
)
760 XML_ExternalEntityParserCreate(XML_Parser parser
,
761 const XML_Char
*context
,
762 const XML_Char
*encoding
);
764 enum XML_ParamEntityParsing
{
765 XML_PARAM_ENTITY_PARSING_NEVER
,
766 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE
,
767 XML_PARAM_ENTITY_PARSING_ALWAYS
770 /* Controls parsing of parameter entities (including the external DTD
771 subset). If parsing of parameter entities is enabled, then
772 references to external parameter entities (including the external
773 DTD subset) will be passed to the handler set with
774 XML_SetExternalEntityRefHandler. The context passed will be 0.
776 Unlike external general entities, external parameter entities can
777 only be parsed synchronously. If the external parameter entity is
778 to be parsed, it must be parsed during the call to the external
779 entity ref handler: the complete sequence of
780 XML_ExternalEntityParserCreate, XML_Parse/XML_ParseBuffer and
781 XML_ParserFree calls must be made during this call. After
782 XML_ExternalEntityParserCreate has been called to create the parser
783 for the external parameter entity (context must be 0 for this
784 call), it is illegal to make any calls on the old parser until
785 XML_ParserFree has been called on the newly created parser.
786 If the library has been compiled without support for parameter
787 entity parsing (ie without XML_DTD being defined), then
788 XML_SetParamEntityParsing will return 0 if parsing of parameter
789 entities is requested; otherwise it will return non-zero.
790 Note: If XML_SetParamEntityParsing is called after XML_Parse or
791 XML_ParseBuffer, then it has no effect and will always return 0.
794 XML_SetParamEntityParsing(XML_Parser parser
,
795 enum XML_ParamEntityParsing parsing
);
797 /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
798 XML_GetErrorCode returns information about the error.
800 XMLPARSEAPI(enum XML_Error
)
801 XML_GetErrorCode(XML_Parser parser
);
803 /* These functions return information about the current parse
804 location. They may be called from any callback called to report
805 some parse event; in this case the location is the location of
806 the first of the sequence of characters that generated the event.
808 They may also be called after returning from a call to XML_Parse
809 or XML_ParseBuffer. If the return value is XML_STATUS_ERROR then
810 the location is the location of the character at which the error
811 was detected; otherwise the location is the location of the last
812 parse event, as described above.
814 XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser
);
815 XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser
);
816 XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser
);
818 /* Return the number of bytes in the current event.
819 Returns 0 if the event is in an internal entity.
822 XML_GetCurrentByteCount(XML_Parser parser
);
824 /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
825 the integer pointed to by offset to the offset within this buffer
826 of the current parse position, and sets the integer pointed to by size
827 to the size of this buffer (the number of input bytes). Otherwise
828 returns a NULL pointer. Also returns a NULL pointer if a parse isn't
831 NOTE: The character pointer returned should not be used outside
832 the handler that makes the call.
834 XMLPARSEAPI(const char *)
835 XML_GetInputContext(XML_Parser parser
,
839 /* For backwards compatibility with previous versions. */
840 #define XML_GetErrorLineNumber XML_GetCurrentLineNumber
841 #define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
842 #define XML_GetErrorByteIndex XML_GetCurrentByteIndex
844 /* Frees the content model passed to the element declaration handler */
846 XML_FreeContentModel(XML_Parser parser
, XML_Content
*model
);
848 /* Exposing the memory handling functions used in Expat */
850 XML_MemMalloc(XML_Parser parser
, size_t size
);
853 XML_MemRealloc(XML_Parser parser
, void *ptr
, size_t size
);
856 XML_MemFree(XML_Parser parser
, void *ptr
);
858 /* Frees memory used by the parser. */
860 XML_ParserFree(XML_Parser parser
);
862 /* Returns a string describing the error. */
863 XMLPARSEAPI(const XML_LChar
*)
864 XML_ErrorString(enum XML_Error code
);
866 /* Return a string containing the version number of this expat */
867 XMLPARSEAPI(const XML_LChar
*)
868 XML_ExpatVersion(void);
876 /* Return an XML_Expat_Version structure containing numeric version
877 number information for this version of expat.
879 XMLPARSEAPI(XML_Expat_Version
)
880 XML_ExpatVersionInfo(void);
882 /* Added in Expat 1.95.5. */
883 enum XML_FeatureEnum
{
886 XML_FEATURE_UNICODE_WCHAR_T
,
888 XML_FEATURE_CONTEXT_BYTES
,
889 XML_FEATURE_MIN_SIZE
,
890 XML_FEATURE_SIZEOF_XML_CHAR
,
891 XML_FEATURE_SIZEOF_XML_LCHAR
892 /* Additional features must be added to the end of this enum. */
896 enum XML_FeatureEnum feature
;
897 const XML_LChar
*name
;
901 XMLPARSEAPI(const XML_Feature
*)
902 XML_GetFeatureList(void);
905 /* Expat follows the GNU/Linux convention of odd number minor version for
906 beta/development releases and even number minor version for stable
907 releases. Micro is bumped with each release, and set to 0 with each
908 change to major or minor version.
910 #define XML_MAJOR_VERSION 1
911 #define XML_MINOR_VERSION 95
912 #define XML_MICRO_VERSION 6
918 #endif /* not XmlParse_INCLUDED */