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

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