📄 xmlparse.h
字号:
/*The contents of this file are subject to the Mozilla Public LicenseVersion 1.1 (the "License"); you may not use this file except incompliance with the License. You may obtain a copy of the License athttp://www.mozilla.org/MPL/Software distributed under the License is distributed on an "AS IS"basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See theLicense for the specific language governing rights and limitationsunder the License.The Original Code is expat.The Initial Developer of the Original Code is James Clark.Portions created by James Clark are Copyright (C) 1998, 1999James Clark. All Rights Reserved.Contributor(s):Alternatively, the contents of this file may be used under the termsof the GNU General Public License (the "GPL"), in which case theprovisions of the GPL are applicable instead of those above. If youwish to allow use of your version of this file only under the terms ofthe GPL and not to allow others to use your version of this file underthe MPL, indicate your decision by deleting the provisions above andreplace them with the notice and other provisions required by theGPL. If you do not delete the provisions above, a recipient may useyour version of this file under either the MPL or the GPL.*/#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 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 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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -