📄 expat.h.in
字号:
/*Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center LtdSee the file COPYING for copying permission.*/#ifndef XmlParse_INCLUDED#define XmlParse_INCLUDED 1#include <stdlib.h>#ifndef XMLPARSEAPI# if defined(__declspec) && !defined(__CYGWIN__)# define XMLPARSEAPI __declspec(dllimport)# else# define XMLPARSEAPI /* nothing */# endif#endif /* not defined XMLPARSEAPI */#ifdef __cplusplusextern "C" {#endiftypedef void *XML_Parser;/* Information is UTF-8 encoded. */typedef char XML_Char;typedef char XML_LChar;enum XML_Content_Type { XML_CTYPE_EMPTY = 1, XML_CTYPE_ANY, XML_CTYPE_MIXED, XML_CTYPE_NAME, XML_CTYPE_CHOICE, XML_CTYPE_SEQ};enum XML_Content_Quant { XML_CQUANT_NONE, XML_CQUANT_OPT, XML_CQUANT_REP, XML_CQUANT_PLUS};/* If type == XML_CTYPE_EMPTY or XML_CTYPE_ANY, then quant will be XML_CQUANT_NONE, and the other fields will be zero or NULL. If type == XML_CTYPE_MIXED, then quant will be NONE or REP and numchildren will contain number of elements that may be mixed in and children point to an array of XML_Content cells that will be all of XML_CTYPE_NAME type with no quantification. If type == XML_CTYPE_NAME, then the name points to the name, and the numchildren field will be zero and children will be NULL. The quant fields indicates any quantifiers placed on the name. CHOICE and SEQ will have name NULL, the number of children in numchildren and children will point, recursively, to an array of XML_Content cells. The EMPTY, ANY, and MIXED types will only occur at top level.*/typedef struct XML_cp XML_Content;struct XML_cp { enum XML_Content_Type type; enum XML_Content_Quant quant; const XML_Char * name; unsigned int numchildren; XML_Content * children;};/* This is called for an element declaration. See above for description of the model argument. It's the caller's responsibility to free model when finished with it.*/typedef void (*XML_ElementDeclHandler) (void *userData, const XML_Char *name, XML_Content *model);void XMLPARSEAPIXML_SetElementDeclHandler(XML_Parser parser, XML_ElementDeclHandler eldecl);/* The Attlist declaration handler is called for *each* attribute. So a single Attlist declaration with multiple attributes declared will generate multiple calls to this handler. The "default" parameter may be NULL in the case of the "#IMPLIED" or "#REQUIRED" keyword. The "isrequired" parameter will be true and the default value will be NULL in the case of "#REQUIRED". If "isrequired" is true and default is non-NULL, then this is a "#FIXED" default. */typedef void (*XML_AttlistDeclHandler) (void *userData, const XML_Char *elname, const XML_Char *attname, const XML_Char *att_type, const XML_Char *dflt, int isrequired);void XMLPARSEAPIXML_SetAttlistDeclHandler(XML_Parser parser, XML_AttlistDeclHandler attdecl); /* The XML declaration handler is called for *both* XML declarations and text declarations. The way to distinguish is that the version parameter will be null for text declarations. The encoding parameter may be null for XML declarations. The standalone parameter will be -1, 0, or 1 indicating respectively that there was no standalone parameter in the declaration, that it was given as no, or that it was given as yes. */typedef void (*XML_XmlDeclHandler) (void *userData, const XML_Char *version, const XML_Char *encoding, int standalone);void XMLPARSEAPIXML_SetXmlDeclHandler(XML_Parser parser, XML_XmlDeclHandler xmldecl);typedef struct { void *(*malloc_fcn)(size_t size); void *(*realloc_fcn)(void *ptr, size_t size); void (*free_fcn)(void *ptr);} XML_Memory_Handling_Suite;/* Constructs a new parser; encoding is the encoding specified by theexternal protocol or null if there is none specified. */XML_Parser XMLPARSEAPIXML_ParserCreate(const XML_Char *encoding);/* Constructs a new parser and namespace processor. Element typenames and attribute names that belong to a namespace will be expanded;unprefixed attribute names are never expanded; unprefixed element typenames are expanded only if there is a default namespace. The expandedname is the concatenation of the namespace URI, the namespaceseparator character, and the local part of the name. If the namespaceseparator is '\0' then the namespace URI and the local part will beconcatenated without any separator. When a namespace is not declared,the name and prefix will be passed through without expansion. */XML_Parser XMLPARSEAPIXML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);/* Constructs a new parser using the memory management suit referred to by memsuite. If memsuite is NULL, then use the standard library memory suite. If namespaceSeparator is non-NULL it creates a parser with namespace processing as described above. The character pointed at will serve as the namespace separator. All further memory operations used for the created parser will come from the given suite.*/XML_Parser XMLPARSEAPIXML_ParserCreate_MM(const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, const XML_Char *namespaceSeparator);/* atts is array of name/value pairs, terminated by 0; names and values are 0 terminated. */typedef void (*XML_StartElementHandler)(void *userData, const XML_Char *name, const XML_Char **atts);typedef void (*XML_EndElementHandler)(void *userData, const XML_Char *name);/* s is not 0 terminated. */typedef void (*XML_CharacterDataHandler)(void *userData, const XML_Char *s, int len);/* target and data are 0 terminated */typedef void (*XML_ProcessingInstructionHandler)(void *userData, const XML_Char *target, const XML_Char *data);/* data is 0 terminated */typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);typedef void (*XML_StartCdataSectionHandler)(void *userData);typedef void (*XML_EndCdataSectionHandler)(void *userData);/* This is called for any characters in the XML document forwhich there is no applicable handler. This includes bothcharacters that are part of markup which is of a kind that isnot reported (comments, markup declarations), or charactersthat are part of a construct which could be reported butfor which no handler has been supplied. The characters are passedexactly as they were in the XML document except thatthey will be encoded in UTF-8. Line boundaries are not normalized.Note that a byte order mark character is not passed to the default handler.There are no guarantees about how characters are divided between callsto the default handler: for example, a comment might be split betweenmultiple calls. */typedef void (*XML_DefaultHandler)(void *userData, const XML_Char *s, int len);/* This is called for the start of the DOCTYPE declaration, before any DTD or internal subset is parsed. */typedef void (*XML_StartDoctypeDeclHandler)(void *userData, const XML_Char *doctypeName, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset );/* This is called for the start of the DOCTYPE declaration when theclosing > is encountered, but after processing any external subset. */typedef void (*XML_EndDoctypeDeclHandler)(void *userData);/* This is called for entity declarations. The is_parameter_entity argument will be non-zero if the entity is a parameter entity, zero otherwise. For internal entities (<!ENTITY foo "bar">), value will be non-null and systemId, publicID, and notationName will be null. The value string is NOT null terminated; the length is provided in the value_length argument. Since it is legal to have zero-length values, do not use this argument to test for internal entities. For external entities, value will be null and systemId will be non-null. The publicId argument will be null unless a public identifier was provided. The notationName argument will have a non-null value only for unparsed entity declarations.*/typedef void (*XML_EntityDeclHandler) (void *userData, const XML_Char *entityName, int is_parameter_entity, const XML_Char *value, int value_length, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName); void XMLPARSEAPIXML_SetEntityDeclHandler(XML_Parser parser, XML_EntityDeclHandler handler);/* OBSOLETE -- OBSOLETE -- OBSOLETE This handler has been superceded by the EntityDeclHandler above. It is provided here for backward compatibility.This is called for a declaration of an unparsed (NDATA)entity. The base argument is whatever was set by XML_SetBase.The entityName, systemId and notationName arguments will never be null.The other arguments may be. */typedef void (*XML_UnparsedEntityDeclHandler)(void *userData, const XML_Char *entityName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId, const XML_Char *notationName);/* This is called for a declaration of notation.The base argument is whatever was set by XML_SetBase.The notationName will never be null. The other arguments can be. */typedef void (*XML_NotationDeclHandler)(void *userData, const XML_Char *notationName, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId);/* When namespace processing is enabled, these are called once foreach namespace declaration. The call to the start and end elementhandlers occur between the calls to the start and end namespacedeclaration handlers. For an xmlns attribute, prefix will be null.For an xmlns="" attribute, uri will be null. */typedef void (*XML_StartNamespaceDeclHandler)(void *userData, const XML_Char *prefix, const XML_Char *uri);typedef void (*XML_EndNamespaceDeclHandler)(void *userData, const XML_Char *prefix);/* This is called if the document is not standalone (it has anexternal subset or a reference to a parameter entity, but does nothave standalone="yes"). If this handler returns 0, then processingwill not continue, and the parser will return aXML_ERROR_NOT_STANDALONE error. */typedef int (*XML_NotStandaloneHandler)(void *userData);/* This is called for a reference to an external parsed general entity.The referenced entity is not automatically parsed.The application can parse it immediately or later usingXML_ExternalEntityParserCreate.The parser argument is the parser parsing the entity containing the reference;it can be passed as the parser argument to XML_ExternalEntityParserCreate.The systemId argument is the system identifier as specified in the entitydeclaration; it will not be null.The base argument is the system identifier that should be used as the base forresolving systemId if systemId was relative; this is set by XML_SetBase;it may be null.The publicId argument is the public identifier as specified in the entitydeclaration, or null if none was specified; the whitespace in the publicidentifier will have been normalized as required by the XML spec.The context argument specifies the parsing context in the formatexpected by the context argument toXML_ExternalEntityParserCreate; context is valid only until the handlerreturns, so if the referenced entity is to be parsed later, it must be copied.The handler should return 0 if processing should not continue because ofa fatal error in the handling of the external entity.In this case the calling parser will return anXML_ERROR_EXTERNAL_ENTITY_HANDLING error.Note that unlike other handlers the first argument is the parser, notuserData. */typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser, const XML_Char *context, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId);/* This structure is filled in by the XML_UnknownEncodingHandlerto provide information to the parser about encodings that are unknownto the parser.The map[b] member gives information about byte sequenceswhose first byte is b.If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalarvalue c.If map[b] is -1, then the byte sequence is malformed.If map[b] is -n, where n >= 2, then b is the first byte of an n-bytesequence that encodes a single Unicode scalar value.The data member will be passed as the first argument to the convert function.The convert function is used to convert multibyte sequences;s will point to a n-byte sequence where map[(unsigned char)*s] == -n.The convert function must return the Unicode scalar valuerepresented by this byte sequence or -1 if the byte sequence is malformed.The convert function may be null if the encoding is a single-byte encoding,that is if map[b] >= -1 for all bytes b.When the parser is finished with the encoding, then if release is not null,it will call release passing it the data member;once release has been called, the convert function will not be called again.Expat places certain restrictions on the encodings that are supportedusing this mechanism.1. Every ASCII character that can appear in a well-formed XML document,other than the characters $@\^`{}~must be represented by a single byte, and that byte must be thesame byte that represents that character in ASCII.2. No character may require more than 4 bytes to encode.3. All characters encoded must have Unicode scalar values <= 0xFFFF,(ie characters that would be encoded by surrogates in UTF-16are not allowed). Note that this restriction doesn't apply tothe built-in support for UTF-8 and UTF-16.4. No Unicode character may be encoded by more than one distinct sequence
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -