source: trunk/include/expat/expat.h@ 201

Last change on this file since 201 was 98, checked in by umoeller, 24 years ago

Misc updates.

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 32.7 KB
Line 
1/*
2Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
3See the file COPYING for copying permission.
4*/
5
6#ifndef XmlParse_INCLUDED
7#define XmlParse_INCLUDED 1
8
9#include <stdlib.h>
10
11#include "expat\expat_setup.h"
12 // V0.9.9 (2001-02-10) [umoeller]
13 // to save the app from having to include this as well
14
15/* #ifndef XMLPARSEAPI
16 #ifdef EXPATENTRY
17 // #define XMLPARSEAPI(type) type EXPATENTRY
18 #define XMLPARSEAPI(type)
19 // V0.9.14 (2001-08-09) [umoeller]
20 #else
21 #define XMLPARSEAPI(type) type
22 #endif
23#endif */
24
25#ifndef XMLPARSEAPI
26# ifdef __declspec
27# define XMLPARSEAPI __declspec(dllimport)
28# else
29# define XMLPARSEAPI /* nothing */
30# endif
31#endif /* not defined XMLPARSEAPI */
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37typedef void *XML_Parser;
38
39/* Information is UTF-8 encoded. */
40typedef char XML_Char;
41typedef char XML_LChar;
42
43enum XML_Content_Type
44{
45 XML_CTYPE_EMPTY = 1,
46 XML_CTYPE_ANY,
47 XML_CTYPE_MIXED,
48 XML_CTYPE_NAME,
49 XML_CTYPE_CHOICE,
50 XML_CTYPE_SEQ
51};
52
53enum XML_Content_Quant
54{
55 XML_CQUANT_NONE,
56 XML_CQUANT_OPT,
57 XML_CQUANT_REP,
58 XML_CQUANT_PLUS
59};
60
61/*
62 *@@ XMLCONTENT:
63 * structure passed with the @expat "element declaration handler"
64 * (see XML_SetElementDeclHandler).
65 *
66 * The model argument is the root of a tree of XMLCONTENT
67 * nodes. If type equals XML_CTYPE_EMPTY or XML_CTYPE_ANY,
68 * then quant will be XML_CQUANT_NONE, and the other fields
69 * will be zero or NULL.
70 *
71 * If type is XML_CTYPE_MIXED:
72 *
73 * -- "quant" will be XML_CQUANT_NONE or XML_CQUANT_REP.
74 *
75 * -- "numchildren" will contain the number of elements that
76 * are allowed to be mixed in.
77 *
78 * -- "children" points to a sub-array of XMLCONTENT structures
79 * that will all have type XML_CTYPE_NAME with no quantification.
80 *
81 * Only the root node can be type XML_CTYPE_EMPTY, XML_CTYPE_ANY,
82 * or XML_CTYPE_MIXED.
83 *
84 * For type XML_CTYPE_NAME, the name field points to the
85 * name and the numchildren and children fields will be
86 * zero and NULL. The quant field will indicate any
87 * quantifiers placed on the name.
88 *
89 * Types XML_CTYPE_CHOICE and XML_CTYPE_SEQ indicate a
90 * choice or sequence respectively. The numchildren field
91 * indicates how many nodes in the choice or sequence and
92 * children points to the nodes.
93 *
94 *@@added V0.9.9 (2001-02-14) [umoeller]
95 */
96
97typedef struct _XMLCONTENT
98{
99 enum XML_Content_Type type;
100 // one of:
101 // -- XML_CTYPE_EMPTY --> quant will be XML_CQUANT_NONE, rest is NULL
102 // -- XML_CTYPE_ANY, --> quant will be XML_CQUANT_NONE, rest is NULL
103 // -- XML_CTYPE_MIXED, --> (#PCDATA) gives us this
104 // -- XML_CTYPE_CHOICE, --> choice ("|" list)
105 // -- XML_CTYPE_SEQ --> sequence (comma list)
106
107 // -- XML_CTYPE_NAME: used for sub-content if content has CML_CTYPE_MIXED;
108 // only "name" is valid for sub-content
109
110 enum XML_Content_Quant quant;
111 // one of:
112 // -- XML_CQUANT_NONE --> all fields below are NULL
113 // -- XML_CQUANT_OPT, question mark
114 // -- XML_CQUANT_REP, asterisk
115 // -- XML_CQUANT_PLUS plus sign
116
117 XML_Char *name;
118
119 unsigned int numchildren;
120
121 struct _XMLCONTENT *children;
122} XMLCONTENT, *PXMLCONTENT;
123
124
125/* This is called for an element declaration. See above for
126 description of the model argument. It's the caller's responsibility
127 to free model when finished with it.
128*/
129
130typedef void (* EXPATENTRY XML_ElementDeclHandler) (void *userData,
131 const XML_Char *name,
132 XMLCONTENT *model);
133
134void EXPATENTRY XML_SetElementDeclHandler(XML_Parser parser,
135 XML_ElementDeclHandler eldecl);
136
137/*
138 The Attlist declaration handler is called for *each* attribute. So
139 a single Attlist declaration with multiple attributes declared will
140 generate multiple calls to this handler. The "default" parameter
141 may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword.
142 The "isrequired" parameter will be true and the default value will
143 be NULL in the case of "#REQUIRED". If "isrequired" is true and
144 default is non-NULL, then this is a "#FIXED" default.
145 */
146
147typedef void (* EXPATENTRY XML_AttlistDeclHandler) (void *userData,
148 const XML_Char *elname,
149 const XML_Char *attname,
150 const XML_Char *att_type,
151 const XML_Char *dflt,
152 int isrequired);
153
154void EXPATENTRY
155XML_SetAttlistDeclHandler(XML_Parser parser,
156 XML_AttlistDeclHandler attdecl);
157
158
159 /* The XML declaration handler is called for *both* XML declarations and
160 text declarations. The way to distinguish is that the version parameter
161 will be null for text declarations. The encoding parameter may be null
162 for XML declarations. The standalone parameter will be -1, 0, or 1
163 indicating respectively that there was no standalone parameter in
164 the declaration, that it was given as no, or that it was given as yes.
165 */
166
167typedef void (* EXPATENTRY XML_XmlDeclHandler) (void *userData,
168 const XML_Char *version,
169 const XML_Char *encoding,
170 int standalone);
171
172void EXPATENTRY
173XML_SetXmlDeclHandler(XML_Parser parser,
174 XML_XmlDeclHandler xmldecl);
175
176
177typedef struct {
178 void *(*malloc_fcn)(size_t size);
179 void *(*realloc_fcn)(void *ptr, size_t size);
180 void (*free_fcn)(void *ptr);
181} XML_Memory_Handling_Suite;
182
183/* Constructs a new parser; encoding is the encoding specified by the
184external protocol or null if there is none specified. */
185
186XML_Parser EXPATENTRY
187XML_ParserCreate(const XML_Char *encoding);
188
189/* Constructs a new parser and namespace processor. Element type
190names and attribute names that belong to a namespace will be expanded;
191unprefixed attribute names are never expanded; unprefixed element type
192names are expanded only if there is a default namespace. The expanded
193name is the concatenation of the namespace URI, the namespace
194separator character, and the local part of the name. If the namespace
195separator is '\0' then the namespace URI and the local part will be
196concatenated without any separator. When a namespace is not declared,
197the name and prefix will be passed through without expansion. */
198
199XML_Parser EXPATENTRY
200XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
201
202
203/* Constructs a new parser using the memory management suit referred to
204 by memsuite. If memsuite is NULL, then use the standard library memory
205 suite. If namespaceSeparator is non-NULL it creates a parser with
206 namespace processing as described above. The character pointed at
207 will serve as the namespace separator.
208
209 All further memory operations used for the created parser will come from
210 the given suite.
211*/
212
213XML_Parser EXPATENTRY
214XML_ParserCreate_MM(const XML_Char *encoding,
215 const XML_Memory_Handling_Suite *memsuite,
216 const XML_Char *namespaceSeparator);
217
218/* atts is array of name/value pairs, terminated by 0;
219 names and values are 0 terminated. */
220
221typedef void (* EXPATENTRY XML_StartElementHandler)(void *userData,
222 const XML_Char *name,
223 const XML_Char **atts);
224
225typedef void (* EXPATENTRY XML_EndElementHandler)(void *userData,
226 const XML_Char *name);
227
228
229/* s is not 0 terminated. */
230typedef void (* EXPATENTRY XML_CharacterDataHandler)(void *userData,
231 const XML_Char *s,
232 int len);
233
234/* target and data are 0 terminated */
235typedef void (* EXPATENTRY XML_ProcessingInstructionHandler)(void *userData,
236 const XML_Char *target,
237 const XML_Char *data);
238
239/* data is 0 terminated */
240typedef void (* EXPATENTRY XML_CommentHandler)(void *userData, const XML_Char *data);
241
242typedef void (* EXPATENTRY XML_StartCdataSectionHandler)(void *userData);
243typedef void (* EXPATENTRY XML_EndCdataSectionHandler)(void *userData);
244
245/* This is called for any characters in the XML document for
246which there is no applicable handler. This includes both
247characters that are part of markup which is of a kind that is
248not reported (comments, markup declarations), or characters
249that are part of a construct which could be reported but
250for which no handler has been supplied. The characters are passed
251exactly as they were in the XML document except that
252they will be encoded in UTF-8. Line boundaries are not normalized.
253Note that a byte order mark character is not passed to the default handler.
254There are no guarantees about how characters are divided between calls
255to the default handler: for example, a comment might be split between
256multiple calls. */
257
258typedef void (* EXPATENTRY XML_DefaultHandler)(void *userData,
259 const XML_Char *s,
260 int len);
261
262/* This is called for the start of the DOCTYPE declaration, before
263 any DTD or internal subset is parsed. */
264
265typedef void (* EXPATENTRY XML_StartDoctypeDeclHandler)(void *userData,
266 const XML_Char *doctypeName,
267 const XML_Char *sysid,
268 const XML_Char *pubid,
269 int has_internal_subset);
270
271/* This is called for the start of the DOCTYPE declaration when the
272closing > is encountered, but after processing any external subset. */
273typedef void (* EXPATENTRY XML_EndDoctypeDeclHandler)(void *userData);
274
275/* This is called for entity declarations. The is_parameter_entity
276 argument will be non-zero if the entity is a parameter entity, zero
277 otherwise.
278
279 For internal entities (<!ENTITY foo "bar">), value will
280 be non-null and systemId, publicID, and notationName will be null.
281 The value string is NOT null terminated; the length is provided in
282 the value_length argument. Since it is legal to have zero-length
283 values, do not use this argument to test for internal entities.
284
285 For external entities, value will be null and systemId will be non-null.
286 The publicId argument will be null unless a public identifier was
287 provided. The notationName argument will have a non-null value only
288 for unparsed entity declarations.
289*/
290
291typedef void (* EXPATENTRY XML_EntityDeclHandler) (void *userData,
292 const XML_Char *entityName,
293 int is_parameter_entity,
294 const XML_Char *value,
295 int value_length,
296 const XML_Char *base,
297 const XML_Char *systemId,
298 const XML_Char *publicId,
299 const XML_Char *notationName);
300
301void EXPATENTRY
302XML_SetEntityDeclHandler(XML_Parser parser,
303 XML_EntityDeclHandler handler);
304
305/* OBSOLETE -- OBSOLETE -- OBSOLETE
306 This handler has been superceded by the EntityDeclHandler above.
307 It is provided here for backward compatibility.
308This is called for a declaration of an unparsed (NDATA)
309entity. The base argument is whatever was set by XML_SetBase.
310The entityName, systemId and notationName arguments will never be null.
311The other arguments may be. */
312
313typedef void (* EXPATENTRY XML_UnparsedEntityDeclHandler)(void *userData,
314 const XML_Char *entityName,
315 const XML_Char *base,
316 const XML_Char *systemId,
317 const XML_Char *publicId,
318 const XML_Char *notationName);
319
320/* This is called for a declaration of notation.
321The base argument is whatever was set by XML_SetBase.
322The notationName will never be null. The other arguments can be. */
323
324typedef void (* EXPATENTRY XML_NotationDeclHandler)(void *userData,
325 const XML_Char *notationName,
326 const XML_Char *base,
327 const XML_Char *systemId,
328 const XML_Char *publicId);
329
330/* When namespace processing is enabled, these are called once for
331each namespace declaration. The call to the start and end element
332handlers occur between the calls to the start and end namespace
333declaration handlers. For an xmlns attribute, prefix will be null.
334For an xmlns="" attribute, uri will be null. */
335
336typedef void (* EXPATENTRY XML_StartNamespaceDeclHandler)(void *userData,
337 const XML_Char *prefix,
338 const XML_Char *uri);
339
340typedef void (* EXPATENTRY XML_EndNamespaceDeclHandler)(void *userData,
341 const XML_Char *prefix);
342
343/* This is called if the document is not standalone (it has an
344external subset or a reference to a parameter entity, but does not
345have standalone="yes"). If this handler returns 0, then processing
346will not continue, and the parser will return a
347ERROR_EXPAT_NOT_STANDALONE error. */
348
349typedef int (* EXPATENTRY XML_NotStandaloneHandler)(void *userData);
350
351/* This is called for a reference to an external parsed general entity.
352The referenced entity is not automatically parsed.
353The application can parse it immediately or later using
354XML_ExternalEntityParserCreate.
355The parser argument is the parser parsing the entity containing the reference;
356it can be passed as the parser argument to XML_ExternalEntityParserCreate.
357The systemId argument is the system identifier as specified in the entity
358declaration; it will not be null.
359The base argument is the system identifier that should be used as the base for
360resolving systemId if systemId was relative; this is set by XML_SetBase;
361it may be null.
362The publicId argument is the public identifier as specified in the entity
363declaration, or null if none was specified; the whitespace in the public
364identifier will have been normalized as required by the XML spec.
365The context argument specifies the parsing context in the format
366expected by the context argument to
367XML_ExternalEntityParserCreate; context is valid only until the handler
368returns, so if the referenced entity is to be parsed later, it must be copied.
369The handler should return 0 if processing should not continue because of
370a fatal error in the handling of the external entity.
371In this case the calling parser will return an
372ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING error.
373Note that unlike other handlers the first argument is the parser, not
374userData. */
375
376typedef int (* EXPATENTRY XML_ExternalEntityRefHandler)(void *userData, // added V0.9.14 (2001-08-09) [umoeller]
377 XML_Parser parser,
378 const XML_Char *context,
379 const XML_Char *base,
380 const XML_Char *systemId,
381 const XML_Char *publicId);
382
383/* This structure is filled in by the XML_UnknownEncodingHandler
384to provide information to the parser about encodings that are unknown
385to the parser.
386The map[b] member gives information about byte sequences
387whose first byte is b.
388If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar
389value c.
390If map[b] is -1, then the byte sequence is malformed.
391If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
392sequence that encodes a single Unicode scalar value.
393The data member will be passed as the first argument to the convert function.
394The convert function is used to convert multibyte sequences;
395s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
396The convert function must return the Unicode scalar value
397represented by this byte sequence or -1 if the byte sequence is malformed.
398The convert function may be null if the encoding is a single-byte encoding,
399that is if map[b] >= -1 for all bytes b.
400When the parser is finished with the encoding, then if release is not null,
401it will call release passing it the data member;
402once release has been called, the convert function will not be called again.
403
404Expat places certain restrictions on the encodings that are supported
405using this mechanism.
406
4071. Every ASCII character that can appear in a well-formed XML document,
408other than the characters
409
410 $@\^`{}~
411
412must be represented by a single byte, and that byte must be the
413same byte that represents that character in ASCII.
414
4152. No character may require more than 4 bytes to encode.
416
4173. All characters encoded must have Unicode scalar values <= 0xFFFF, (i.e.,
418characters that would be encoded by surrogates in UTF-16 are not
419allowed). Note that this restriction doesn't apply to the built-in
420support for UTF-8 and UTF-16.
421
4224. No Unicode character may be encoded by more than one distinct sequence
423of bytes. */
424
425typedef struct {
426 int map[256];
427 void *data;
428 int (* EXPATENTRY convert)(void *data, const char *s);
429 void (* EXPATENTRY release)(void *data);
430} XML_Encoding;
431
432/* This is called for an encoding that is unknown to the parser.
433The encodingHandlerData argument is that which was passed as the
434second argument to XML_SetUnknownEncodingHandler.
435The name argument gives the name of the encoding as specified in
436the encoding declaration.
437If the callback can provide information about the encoding,
438it must fill in the XML_Encoding structure, and return 1.
439Otherwise it must return 0.
440If info does not describe a suitable encoding,
441then the parser will return an XML_UNKNOWN_ENCODING error. */
442
443typedef int (* EXPATENTRY XML_UnknownEncodingHandler)(void *encodingHandlerData,
444 const XML_Char *name,
445 XML_Encoding *info);
446
447void EXPATENTRY
448XML_SetElementHandler(XML_Parser parser,
449 XML_StartElementHandler start,
450 XML_EndElementHandler end);
451
452void EXPATENTRY
453XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
454
455void EXPATENTRY
456XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
457
458void EXPATENTRY
459XML_SetCharacterDataHandler(XML_Parser parser,
460 XML_CharacterDataHandler handler);
461
462void EXPATENTRY
463XML_SetProcessingInstructionHandler(XML_Parser parser,
464 XML_ProcessingInstructionHandler handler);
465void EXPATENTRY
466XML_SetCommentHandler(XML_Parser parser,
467 XML_CommentHandler handler);
468
469void EXPATENTRY
470XML_SetCdataSectionHandler(XML_Parser parser,
471 XML_StartCdataSectionHandler start,
472 XML_EndCdataSectionHandler end);
473
474void EXPATENTRY
475XML_SetStartCdataSectionHandler(XML_Parser parser,
476 XML_StartCdataSectionHandler start);
477
478void EXPATENTRY
479XML_SetEndCdataSectionHandler(XML_Parser parser,
480 XML_EndCdataSectionHandler end);
481
482/* This sets the default handler and also inhibits expansion of
483internal entities. The entity reference will be passed to the default
484handler. */
485
486void EXPATENTRY
487XML_SetDefaultHandler(XML_Parser parser,
488 XML_DefaultHandler handler);
489
490/* This sets the default handler but does not inhibit expansion of
491internal entities. The entity reference will not be passed to the
492default handler. */
493
494void EXPATENTRY
495XML_SetDefaultHandlerExpand(XML_Parser parser,
496 XML_DefaultHandler handler);
497
498void EXPATENTRY
499XML_SetDoctypeDeclHandler(XML_Parser parser,
500 XML_StartDoctypeDeclHandler start,
501 XML_EndDoctypeDeclHandler end);
502
503void EXPATENTRY
504XML_SetStartDoctypeDeclHandler(XML_Parser parser,
505 XML_StartDoctypeDeclHandler start);
506
507void EXPATENTRY
508XML_SetEndDoctypeDeclHandler(XML_Parser parser,
509 XML_EndDoctypeDeclHandler end);
510
511void EXPATENTRY
512XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
513 XML_UnparsedEntityDeclHandler handler);
514
515void EXPATENTRY
516XML_SetNotationDeclHandler(XML_Parser parser,
517 XML_NotationDeclHandler handler);
518
519void EXPATENTRY
520XML_SetNamespaceDeclHandler(XML_Parser parser,
521 XML_StartNamespaceDeclHandler start,
522 XML_EndNamespaceDeclHandler end);
523
524void EXPATENTRY
525XML_SetStartNamespaceDeclHandler(XML_Parser parser,
526 XML_StartNamespaceDeclHandler start);
527
528void EXPATENTRY
529XML_SetEndNamespaceDeclHandler(XML_Parser parser,
530 XML_EndNamespaceDeclHandler end);
531
532void EXPATENTRY
533XML_SetNotStandaloneHandler(XML_Parser parser,
534 XML_NotStandaloneHandler handler);
535
536void EXPATENTRY
537XML_SetExternalEntityRefHandler(XML_Parser parser,
538 XML_ExternalEntityRefHandler handler);
539
540/* If a non-null value for arg is specified here, then it will be passed
541as the first argument to the external entity ref handler instead
542of the parser object. */
543void EXPATENTRY
544XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
545
546void EXPATENTRY
547XML_SetUnknownEncodingHandler(XML_Parser parser,
548 XML_UnknownEncodingHandler handler,
549 void *encodingHandlerData);
550
551/* This can be called within a handler for a start element, end element,
552processing instruction or character data. It causes the corresponding
553markup to be passed to the default handler. */
554void EXPATENTRY
555XML_DefaultCurrent(XML_Parser parser);
556
557/* If do_nst is non-zero, and namespace processing is in effect, and
558 a name has a prefix (i.e. an explicit namespace qualifier) then
559 that name is returned as a triplet in a single
560 string separated by the separator character specified when the parser
561 was created: URI + sep + local_name + sep + prefix.
562
563 If do_nst is zero, then namespace information is returned in the
564 default manner (URI + sep + local_name) whether or not the names
565 has a prefix.
566*/
567
568void EXPATENTRY
569XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
570
571/* This value is passed as the userData argument to callbacks. */
572void EXPATENTRY
573XML_SetUserData(XML_Parser parser, void *userData);
574
575/* Returns the last value set by XML_SetUserData or null. */
576#define XML_GetUserData(parser) (*(void **)(parser))
577
578/* This is equivalent to supplying an encoding argument
579to XML_ParserCreate. It must not be called after XML_Parse
580or XML_ParseBuffer. */
581
582int EXPATENTRY
583XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
584
585/* If this function is called, then the parser will be passed
586as the first argument to callbacks instead of userData.
587The userData will still be accessible using XML_GetUserData. */
588
589void EXPATENTRY
590XML_UseParserAsHandlerArg(XML_Parser parser);
591
592/* Sets the base to be used for resolving relative URIs in system
593identifiers in declarations. Resolving relative identifiers is left
594to the application: this value will be passed through as the base
595argument to the XML_ExternalEntityRefHandler, XML_NotationDeclHandler
596and XML_UnparsedEntityDeclHandler. The base argument will be copied.
597Returns zero if out of memory, non-zero otherwise. */
598
599int EXPATENTRY
600XML_SetBase(XML_Parser parser, const XML_Char *base);
601
602const XML_Char * EXPATENTRY
603XML_GetBase(XML_Parser parser);
604
605/* Returns the number of the attribute/value pairs passed in last call
606to the XML_StartElementHandler that were specified in the start-tag
607rather than defaulted. Each attribute/value pair counts as 2; thus
608this correspondds to an index into the atts array passed to the
609XML_StartElementHandler. */
610
611int EXPATENTRY
612XML_GetSpecifiedAttributeCount(XML_Parser parser);
613
614/* Returns the index of the ID attribute passed in the last call to
615XML_StartElementHandler, or -1 if there is no ID attribute. Each
616attribute/value pair counts as 2; thus this correspondds to an index
617into the atts array passed to the XML_StartElementHandler. */
618
619int EXPATENTRY
620XML_GetIdAttributeIndex(XML_Parser parser);
621
622/* Parses some input. Returns 0 if a fatal error is detected.
623The last call to XML_Parse must have isFinal true;
624len may be zero for this call (or any other). */
625int EXPATENTRY
626XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
627
628void * EXPATENTRY
629XML_GetBuffer(XML_Parser parser, int len);
630
631int EXPATENTRY
632XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
633
634/* Creates an XML_Parser object that can parse an external general
635entity; context is a '\0'-terminated string specifying the parse
636context; encoding is a '\0'-terminated string giving the name of the
637externally specified encoding, or null if there is no externally
638specified encoding. The context string consists of a sequence of
639tokens separated by formfeeds (\f); a token consisting of a name
640specifies that the general entity of the name is open; a token of the
641form prefix=uri specifies the namespace for a particular prefix; a
642token of the form =uri specifies the default namespace. This can be
643called at any point after the first call to an
644ExternalEntityRefHandler so longer as the parser has not yet been
645freed. The new parser is completely independent and may safely be
646used in a separate thread. The handlers and userData are initialized
647from the parser argument. Returns 0 if out of memory. Otherwise
648returns a new XML_Parser object. */
649XML_Parser EXPATENTRY
650XML_ExternalEntityParserCreate(XML_Parser parser,
651 const XML_Char *context,
652 const XML_Char *encoding);
653
654enum XML_ParamEntityParsing {
655 XML_PARAM_ENTITY_PARSING_NEVER,
656 XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE,
657 XML_PARAM_ENTITY_PARSING_ALWAYS
658};
659
660/* Controls parsing of parameter entities (including the external DTD
661subset). If parsing of parameter entities is enabled, then references
662to external parameter entities (including the external DTD subset)
663will be passed to the handler set with
664XML_SetExternalEntityRefHandler. The context passed will be 0.
665Unlike external general entities, external parameter entities can only
666be parsed synchronously. If the external parameter entity is to be
667parsed, it must be parsed during the call to the external entity ref
668handler: the complete sequence of XML_ExternalEntityParserCreate,
669XML_Parse/XML_ParseBuffer and XML_ParserFree calls must be made during
670this call. After XML_ExternalEntityParserCreate has been called to
671create the parser for the external parameter entity (context must be 0
672for this call), it is illegal to make any calls on the old parser
673until XML_ParserFree has been called on the newly created parser. If
674the library has been compiled without support for parameter entity
675parsing (ie without XML_DTD being defined), then
676XML_SetParamEntityParsing will return 0 if parsing of parameter
677entities is requested; otherwise it will return non-zero. */
678
679int EXPATENTRY
680XML_SetParamEntityParsing(XML_Parser parser,
681 enum XML_ParamEntityParsing parsing);
682
683/* XMLERROR {
684 ERROR_EXPAT_NONE,
685 ERROR_EXPAT_NO_MEMORY,
686 ERROR_EXPAT_SYNTAX,
687 ERROR_EXPAT_NO_ELEMENTS,
688 ERROR_EXPAT_INVALID_TOKEN,
689 ERROR_EXPAT_UNCLOSED_TOKEN,
690 ERROR_EXPAT_PARTIAL_CHAR,
691 ERROR_EXPAT_TAG_MISMATCH,
692 ERROR_EXPAT_DUPLICATE_ATTRIBUTE,
693 ERROR_EXPAT_JUNK_AFTER_DOC_ELEMENT,
694 ERROR_EXPAT_PARAM_ENTITY_REF,
695 ERROR_EXPAT_UNDEFINED_ENTITY,
696 ERROR_EXPAT_RECURSIVE_ENTITY_REF,
697 ERROR_EXPAT_ASYNC_ENTITY,
698 ERROR_EXPAT_BAD_CHAR_REF,
699 ERROR_EXPAT_BINARY_ENTITY_REF,
700 ERROR_EXPAT_ATTRIBUTE_EXTERNAL_ENTITY_REF,
701 ERROR_EXPAT_MISPLACED_XML_PI,
702 ERROR_EXPAT_UNKNOWN_ENCODING,
703 ERROR_EXPAT_INCORRECT_ENCODING,
704 ERROR_EXPAT_UNCLOSED_CDATA_SECTION,
705 ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING,
706 ERROR_EXPAT_NOT_STANDALONE,
707 ERROR_EXPAT_UNEXPECTED_STATE
708}; */
709
710#define ERROR_XML_FIRST 40000 // first error code used
711
712typedef unsigned long XMLERROR; // V0.9.12 (2001-05-20) [umoeller]
713
714#define ERROR_EXPAT_NONE 0
715#define ERROR_EXPAT_NO_MEMORY (ERROR_XML_FIRST)
716#define ERROR_EXPAT_SYNTAX (ERROR_XML_FIRST + 1)
717#define ERROR_EXPAT_NO_ELEMENTS (ERROR_XML_FIRST + 2)
718#define ERROR_EXPAT_INVALID_TOKEN (ERROR_XML_FIRST + 3)
719#define ERROR_EXPAT_UNCLOSED_TOKEN (ERROR_XML_FIRST + 4)
720#define ERROR_EXPAT_PARTIAL_CHAR (ERROR_XML_FIRST + 5)
721#define ERROR_EXPAT_TAG_MISMATCH (ERROR_XML_FIRST + 6)
722#define ERROR_EXPAT_DUPLICATE_ATTRIBUTE (ERROR_XML_FIRST + 7)
723#define ERROR_EXPAT_JUNK_AFTER_DOC_ELEMENT (ERROR_XML_FIRST + 8)
724#define ERROR_EXPAT_PARAM_ENTITY_REF (ERROR_XML_FIRST + 10)
725#define ERROR_EXPAT_UNDEFINED_ENTITY (ERROR_XML_FIRST + 11)
726#define ERROR_EXPAT_RECURSIVE_ENTITY_REF (ERROR_XML_FIRST + 12)
727#define ERROR_EXPAT_ASYNC_ENTITY (ERROR_XML_FIRST + 13)
728#define ERROR_EXPAT_BAD_CHAR_REF (ERROR_XML_FIRST + 14)
729#define ERROR_EXPAT_BINARY_ENTITY_REF (ERROR_XML_FIRST + 15)
730#define ERROR_EXPAT_ATTRIBUTE_EXTERNAL_ENTITY_REF (ERROR_XML_FIRST + 16)
731#define ERROR_EXPAT_MISPLACED_XML_PI (ERROR_XML_FIRST + 17)
732#define ERROR_EXPAT_UNKNOWN_ENCODING (ERROR_XML_FIRST + 18)
733#define ERROR_EXPAT_INCORRECT_ENCODING (ERROR_XML_FIRST + 19)
734#define ERROR_EXPAT_UNCLOSED_CDATA_SECTION (ERROR_XML_FIRST + 20)
735#define ERROR_EXPAT_EXTERNAL_ENTITY_HANDLING (ERROR_XML_FIRST + 21)
736#define ERROR_EXPAT_NOT_STANDALONE (ERROR_XML_FIRST + 22)
737#define ERROR_EXPAT_UNEXPECTED_STATE (ERROR_XML_FIRST + 23)
738
739/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
740returns information about the error. */
741
742XMLERROR EXPATENTRY
743XML_GetErrorCode(XML_Parser parser);
744
745/* These functions return information about the current parse location.
746They may be called when XML_Parse or XML_ParseBuffer return 0;
747in this case the location is the location of the character at which
748the error was detected.
749They may also be called from any other callback called to report
750some parse event; in this the location is the location of the first
751of the sequence of characters that generated the event. */
752
753int EXPATENTRY XML_GetCurrentLineNumber(XML_Parser parser);
754int EXPATENTRY XML_GetCurrentColumnNumber(XML_Parser parser);
755long EXPATENTRY XML_GetCurrentByteIndex(XML_Parser parser);
756
757/* Return the number of bytes in the current event.
758Returns 0 if the event is in an internal entity. */
759
760int EXPATENTRY
761XML_GetCurrentByteCount(XML_Parser parser);
762
763/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
764 the integer pointed to by offset to the offset within this buffer
765 of the current parse position, and sets the integer pointed to by size
766 to the size of this buffer (the number of input bytes). Otherwise
767 returns a null pointer. Also returns a null pointer if a parse isn't
768 active.
769
770 NOTE: The character pointer returned should not be used outside
771 the handler that makes the call. */
772
773const char * EXPATENTRY
774XML_GetInputContext(XML_Parser parser,
775 int *offset,
776 int *size);
777
778/* For backwards compatibility with previous versions. */
779#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
780#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
781#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
782
783/* Frees memory used by the parser. */
784void EXPATENTRY
785XML_ParserFree(XML_Parser parser);
786
787/* Returns a string describing the error. */
788const XML_LChar * EXPATENTRY
789XML_ErrorString(int code);
790
791/* Return a string containing the version number of this expat */
792const XML_LChar * EXPATENTRY
793XML_ExpatVersion(void);
794
795typedef struct {
796 int major;
797 int minor;
798 int micro;
799} XML_Expat_Version;
800
801/* Return an XML_Expat_Version structure containing numeric version
802 number information for this version of expat */
803
804XML_Expat_Version EXPATENTRY
805XML_ExpatVersionInfo(void);
806
807#define XML_MAJOR_VERSION @EXPAT_MAJOR_VERSION@
808#define XML_MINOR_VERSION @EXPAT_MINOR_VERSION@
809#define XML_MICRO_VERSION @EXPAT_EDIT@
810
811#ifdef __cplusplus
812}
813#endif
814
815#endif /* not XmlParse_INCLUDED */
Note: See TracBrowser for help on using the repository browser.