2
0

expat.h.in 26 KB

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