⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlparse.h

📁 一个用visual studio C++开发的XML文件解析和生成程序.
💻 H
📖 第 1 页 / 共 2 页
字号:
/*Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center LtdSee the file copying.txt for copying permission.*/#ifndef XmlParse_INCLUDED#define XmlParse_INCLUDED 1#ifdef __cplusplusextern "C" {#endif#ifndef XMLPARSEAPI#define XMLPARSEAPI /* as nothing */#endiftypedef void *XML_Parser;#ifdef XML_UNICODE_WCHAR_T/* XML_UNICODE_WCHAR_T will work only if sizeof(wchar_t) == 2 and wchar_tuses Unicode. *//* Information is UTF-16 encoded as wchar_ts */#ifndef XML_UNICODE#define XML_UNICODE#endif#include <stddef.h>typedef wchar_t XML_Char;typedef wchar_t XML_LChar;#else /* not XML_UNICODE_WCHAR_T */#ifdef XML_UNICODE/* Information is UTF-16 encoded as unsigned shorts */typedef unsigned short XML_Char;typedef char XML_LChar;#else /* not XML_UNICODE *//* Information is UTF-8 encoded. */typedef char XML_Char;typedef char XML_LChar;#endif /* not XML_UNICODE */#endif /* not XML_UNICODE_WCHAR_T *//* Constructs a new parser; encoding is the encoding specified by the externalprotocol or null if there is none specified. */XML_Parser XMLPARSEAPIXML_ParserCreate(const XML_Char *encoding);/* Constructs a new parser and namespace processor.  Element type namesand 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 namespace separator character,and the local part of the name.  If the namespace separator is '\0' thenthe namespace URI and the local part will be concatenated without anyseparator.  When a namespace is not declared, the name and prefix will bepassed through without expansion. */XML_Parser XMLPARSEAPIXML_ParserCreateNS(const XML_Char *encoding, 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 when thename of the DOCTYPE is encountered. */typedef void (*XML_StartDoctypeDeclHandler)(void *userData,					    const XML_Char *doctypeName);/* 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 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);typedef void (*XML_ExternalParsedEntityDeclHandler)(void *userData,						    const XML_Char *entityName,						    const XML_Char *base,						    const XML_Char *systemId,						    const XML_Char *publicId);typedef void (*XML_InternalParsedEntityDeclHandler)(void *userData,						    const XML_Char *entityName,						    const XML_Char *replacementText,						    int replacementTextLength);/* 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 entity declaration;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 entity declaration,or null if none was specified; the whitespace in the public identifierwill 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 an XML_ERROR_EXTERNAL_ENTITY_HANDLINGerror.Note that unlike other handlers the first argument is the parser, not userData. */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 scalar value 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 sequenceof bytes. */typedef struct {  int map[256];  void *data;  int (*convert)(void *data, const char *s);  void (*release)(void *data);} XML_Encoding;/* This is called for an encoding that is unknown to the parser.The encodingHandlerData argument is that which was passed as thesecond argument to XML_SetUnknownEncodingHandler.The name argument gives the name of the encoding as specified inthe encoding declaration.If the callback can provide information about the encoding,it must fill in the XML_Encoding structure, and return 1.Otherwise it must return 0.If info does not describe a suitable encoding,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -