X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5e9f25245196606cd95bf05897c1d6720f6db081..d7c37bdf337d7ca687263520de432eee4a3722db:/src/expat/doc/reference.html?ds=sidebyside diff --git a/src/expat/doc/reference.html b/src/expat/doc/reference.html index 1d94279e84..8811a3397c 100644 --- a/src/expat/doc/reference.html +++ b/src/expat/doc/reference.html @@ -13,7 +13,17 @@ -

Expat XML Parser

+ + + + + + + + + +
(Expat logo)
Release 2.0.1
+

Expat is a library, written in C, for parsing XML documents. It's the underlying XML parser for the open source Mozilla project, Perl's @@ -31,9 +41,13 @@ href="../COPYING">MIT/X Consortium license. You may download it from the Expat home page.

-

The bulk of this document was originally commissioned as an article by -XML.com. They graciously allowed -Clark Cooper to retain copyright and to distribute it with Expat.

+

The bulk of this document was originally commissioned as an article +by XML.com. They graciously allowed +Clark Cooper to retain copyright and to distribute it with Expat. +This version has been substantially extended to include documentation +on features which have been added since the original article was +published, and additional information on using the original +interface.


Table of Contents

@@ -58,6 +72,9 @@ Clark Cooper to retain copyright and to distribute it with Expat.

  • XML_Parse
  • XML_ParseBuffer
  • XML_GetBuffer
  • +
  • XML_StopParser
  • +
  • XML_ResumeParser
  • +
  • XML_GetParsingStatus
  • Handler Setting Functions @@ -112,8 +129,10 @@ Clark Cooper to retain copyright and to distribute it with Expat.

  • XML_GetBase
  • XML_GetSpecifiedAttributeCount
  • XML_GetIdAttributeIndex
  • +
  • XML_GetAttributeInfo
  • XML_SetEncoding
  • XML_SetParamEntityParsing
  • +
  • XML_SetHashSalt
  • XML_UseForeignDTD
  • XML_SetReturnNSTriplet
  • XML_DefaultCurrent
  • @@ -182,7 +201,7 @@ variable.

     int Depth;
     
    -void
    +void XMLCALL
     start(void *data, const char *el, const char **attr) {
       int i;
     
    @@ -203,12 +222,44 @@ start(void *data, const char *el, const char **attr) {
     

    The end tag simply does the bookkeeping work of decrementing Depth.

    -void
    +void XMLCALL
     end(void *data, const char *el) {
       Depth--;
     }  /* End of end handler */
     
    +

    Note the XMLCALL annotation used for the callbacks. +This is used to ensure that the Expat and the callbacks are using the +same calling convention in case the compiler options used for Expat +itself and the client code are different. Expat tries not to care +what the default calling convention is, though it may require that it +be compiled with a default convention of "cdecl" on some platforms. +For code which uses Expat, however, the calling convention is +specified by the XMLCALL annotation on most platforms; +callbacks should be defined using this annotation.

    + +

    The XMLCALL annotation was added in Expat 1.95.7, but +existing working Expat applications don't need to add it (since they +are already using the "cdecl" calling convention, or they wouldn't be +working). The annotation is only needed if the default calling +convention may be something other than "cdecl". To use the annotation +safely with older versions of Expat, you can conditionally define it +after including Expat's header file:

    + +
    +#include <expat.h>
    +
    +#ifndef XMLCALL
    +#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
    +#define XMLCALL __cdecl
    +#elif defined(__GNUC__)
    +#define XMLCALL __attribute__((cdecl))
    +#else
    +#define XMLCALL
    +#endif
    +#endif
    +
    +

    After creating the parser, the main program just has the job of shoveling the document to the parser so that it can do its work.

    @@ -242,9 +293,9 @@ and you have permission on your system to install into /usr/local, you can install Expat with this sequence of commands:

    -   ./configure
    -   make
    -   make install
    +./configure
    +make
    +make install
     

    There are some options that you can provide to this script, but the @@ -260,6 +311,73 @@ library and header would get installed in /home/me/mystuff/lib and /home/me/mystuff/include respectively.

    +

    Configuring Expat Using the Pre-Processor

    + +

    Expat's feature set can be configured using a small number of +pre-processor definitions. The definition of this symbols does not +affect the set of entry points for Expat, only the behavior of the API +and the definition of character types in the case of +XML_UNICODE_WCHAR_T. The symbols are:

    + +
    +
    XML_DTD
    +
    Include support for using and reporting DTD-based content. If +this is defined, default attribute values from an external DTD subset +are reported and attribute value normalization occurs based on the +type of attributes defined in the external subset. Without +this, Expat has a smaller memory footprint and can be faster, but will +not load external entities or process conditional sections. This does +not affect the set of functions available in the API.
    + +
    XML_NS
    +
    When defined, support for the Namespaces in XML +specification is included.
    + +
    XML_UNICODE
    +
    When defined, character data reported to the application is +encoded in UTF-16 using wide characters of the type +XML_Char. This is implied if +XML_UNICODE_WCHAR_T is defined.
    + +
    XML_UNICODE_WCHAR_T
    +
    If defined, causes the XML_Char character type to be +defined using the wchar_t type; otherwise, unsigned +short is used. Defining this implies +XML_UNICODE.
    + +
    XML_LARGE_SIZE
    +
    If defined, causes the XML_Size and XML_Index +integer types to be at least 64 bits in size. This is intended to support +processing of very large input streams, where the return values of +XML_GetCurrentByteIndex, +XML_GetCurrentLineNumber and +XML_GetCurrentColumnNumber +could overflow. It may not be supported by all compilers, and is turned +off by default.
    + +
    XML_CONTEXT_BYTES
    +
    The number of input bytes of markup context which the parser will +ensure are available for reporting via XML_GetInputContext. This is +normally set to 1024, and must be set to a positive interger. If this +is not defined, the input context will not be available and XML_GetInputContext will +always report NULL. Without this, Expat has a smaller memory +footprint and can be faster.
    + +
    XML_STATIC
    +
    On Windows, this should be set if Expat is going to be linked +statically with the code that calls it; this is required to get all +the right MSVC magic annotations correct. This is ignored on other +platforms.
    + +
    XML_ATTR_INFO
    +
    If defined, makes the the additional function XML_GetAttributeInfo available +for reporting attribute byte offsets.
    +
    +

    Using Expat

    @@ -273,7 +391,7 @@ needs to link against the Expat library. On Unix systems, this would usually be done with the -lexpat argument. Otherwise, you'll need to tell the compiler where to look for the Expat header and the linker where to find the Expat library. You may also need to -take steps to tell the operating system where to find this libary at +take steps to tell the operating system where to find this library at run time.

    On a Unix-based system, here's what a Makefile might look like when @@ -318,7 +436,7 @@ by these functions is an opaque pointer (i.e. "expat.h" declares it as void *) to data with further internal structure. In order to free the memory associated with this object you must call XML_ParserFree. Note that if you have -provided any user data that gets stored in the +provided any user data that gets stored in the parser, then your application is responsible for freeing it prior to calling XML_ParserFree.

    @@ -360,7 +478,7 @@ init_info(Parseinfo *info) { /* Other initializations here */ } /* End of init_info */ -void +void XMLCALL rawstart(void *data, const char *el, const char **attr) { Parseinfo *inf = (Parseinfo *) data; @@ -375,7 +493,7 @@ rawstart(void *data, const char *el, const char **attr) { inf->depth++; } /* End of rawstart */ -void +void XMLCALL rawend(void *data, const char *el) { Parseinfo *inf = (Parseinfo *) data; @@ -405,8 +523,31 @@ handler.

    without using globals, you'll need to define a data structure to hold the shared variables. You can then tell Expat (with the XML_SetUserData function) to pass a -pointer to this structure to the handlers. This is typically the first -argument received by most handlers.

    +pointer to this structure to the handlers. This is the first +argument received by most handlers. In the reference section, an argument to a callback function is named +userData and have type void * if the user +data is passed; it will have the type XML_Parser if the +parser itself is passed. When the parser is passed, the user data may +be retrieved using XML_GetUserData.

    + +

    One common case where multiple calls to a single handler may need +to communicate using an application data structure is the case when +content passed to the character data handler (set by XML_SetCharacterDataHandler) needs to be accumulated. A +common first-time mistake with any of the event-oriented interfaces to +an XML parser is to expect all the text contained in an element to be +reported by a single call to the character data handler. Expat, like +many other XML parsers, reports such data as a sequence of calls; +there's no way to know when the end of the sequence is reached until a +different callback is made. A buffer referenced by the user data +structure proves both an effective and convenient place to accumulate +character data.

    + + +

    XML Version

    @@ -425,7 +566,7 @@ version number of "1.0" is accepted:

    static int wrong_version; static XML_Parser parser; -static void +static void XMLCALL xmldecl_handler(void *userData, const XML_Char *version, const XML_Char *encoding, @@ -467,12 +608,12 @@ this expanded form is a concatenation of the namespace URI, the separator character (which is the 2nd argument to XML_ParserCreateNS), and the local name (i.e. the part after the colon). Names with undeclared prefixes -are passed through to the handlers unchanged, with the prefix and -colon still attached. Unprefixed attribute names are never expanded, +are not well-formed when namespace processing is enabled, and will +trigger an error. Unprefixed attribute names are never expanded, and unprefixed element names are only expanded when they are in the scope of a default namespace.

    -

    However if However if XML_SetReturnNSTriplet has been called with a non-zero do_nst parameter, then the expanded form for names with an explicit prefix is a concatenation of: URI, separator, local name, @@ -482,7 +623,7 @@ separator, prefix.

    for the end of a scope of a declaration with the XML_SetNamespaceDeclHandler function. The StartNamespaceDeclHandler is called prior to the start -tag handler and the EndNamespaceDeclHandler is called before the +tag handler and the EndNamespaceDeclHandler is called after the corresponding end tag that ends the namespace's scope. The namespace start handler gets passed the prefix and URI for the namespace. For a default namespace declaration (xmlns='...'), the prefix will be null. @@ -607,6 +748,149 @@ arguments:

    In order to read an external DTD, you also have to set an external entity reference handler as described above.

    +

    Temporarily Stopping Parsing

    + +

    Expat 1.95.8 introduces a new feature: its now possible to stop +parsing temporarily from within a handler function, even if more data +has already been passed into the parser. Applications for this +include

    + +
      +
    • Supporting the XInclude specification.
    • + +
    • Delaying further processing until additional information is + available from some other source.
    • + +
    • Adjusting processor load as task priorities shift within an + application.
    • + +
    • Stopping parsing completely (simply free or reset the parser + instead of resuming in the outer parsing loop). This can be useful + if a application-domain error is found in the XML being parsed or if + the result of the parse is determined not to be useful after + all.
    • +
    + +

    To take advantage of this feature, the main parsing loop of an +application needs to support this specifically. It cannot be +supported with a parsing loop compatible with Expat 1.95.7 or +earlier (though existing loops will continue to work without +supporting the stop/resume feature).

    + +

    An application that uses this feature for a single parser will have +the rough structure (in pseudo-code):

    + +
    +fd = open_input()
    +p = create_parser()
    +
    +if parse_xml(p, fd) {
    +  /* suspended */
    +
    +  int suspended = 1;
    +
    +  while (suspended) {
    +    do_something_else()
    +    if ready_to_resume() {
    +      suspended = continue_parsing(p, fd);
    +    }
    +  }
    +}
    +
    + +

    An application that may resume any of several parsers based on +input (either from the XML being parsed or some other source) will +certainly have more interesting control structures.

    + +

    This C function could be used for the parse_xml +function mentioned in the pseudo-code above:

    + +
    +#define BUFF_SIZE 10240
    +
    +/* Parse a document from the open file descriptor 'fd' until the parse
    +   is complete (the document has been completely parsed, or there's
    +   been an error), or the parse is stopped.  Return non-zero when
    +   the parse is merely suspended.
    +*/
    +int
    +parse_xml(XML_Parser p, int fd)
    +{
    +  for (;;) {
    +    int last_chunk;
    +    int bytes_read;
    +    enum XML_Status status;
    +
    +    void *buff = XML_GetBuffer(p, BUFF_SIZE);
    +    if (buff == NULL) {
    +      /* handle error... */
    +      return 0;
    +    }
    +    bytes_read = read(fd, buff, BUFF_SIZE);
    +    if (bytes_read < 0) {
    +      /* handle error... */
    +      return 0;
    +    }
    +    status = XML_ParseBuffer(p, bytes_read, bytes_read == 0);
    +    switch (status) {
    +      case XML_STATUS_ERROR:
    +        /* handle error... */
    +        return 0;
    +      case XML_STATUS_SUSPENDED:
    +        return 1;
    +    }
    +    if (bytes_read == 0)
    +      return 0;
    +  }
    +}
    +
    + +

    The corresponding continue_parsing function is +somewhat simpler, since it only need deal with the return code from +XML_ResumeParser; it can +delegate the input handling to the parse_xml +function:

    + +
    +/* Continue parsing a document which had been suspended.  The 'p' and
    +   'fd' arguments are the same as passed to parse_xml().  Return
    +   non-zero when the parse is suspended.
    +*/
    +int
    +continue_parsing(XML_Parser p, int fd)
    +{
    +  enum XML_Status status = XML_ResumeParser(p);
    +  switch (status) {
    +    case XML_STATUS_ERROR:
    +      /* handle error... */
    +      return 0;
    +    case XML_ERROR_NOT_SUSPENDED:
    +      /* handle error... */
    +      return 0;.
    +    case XML_STATUS_SUSPENDED:
    +      return 1;
    +  }
    +  return parse_xml(p, fd);
    +}
    +
    + +

    Now that we've seen what a mess the top-level parsing loop can +become, what have we gained? Very simply, we can now use the XML_StopParser function to stop +parsing, without having to go to great lengths to avoid additional +processing that we're expecting to ignore. As a bonus, we get to stop +parsing temporarily, and come back to it when we're +ready.

    + +

    To stop parsing from a handler function, use the XML_StopParser function. This function +takes two arguments; the parser being stopped and a flag indicating +whether the parse can be resumed in the future.

    + + + +
    @@ -615,7 +899,7 @@ entity reference handler as described above.

    Parser Creation

    -XML_Parser
    +XML_Parser XMLCALL
     XML_ParserCreate(const XML_Char *encoding);
     
    @@ -632,7 +916,7 @@ Any other value will invoke a call to the UnknownEncodingHandler.
    -XML_Parser
    +XML_Parser XMLCALL
     XML_ParserCreateNS(const XML_Char *encoding,
                        XML_Char sep);
     
    @@ -640,20 +924,27 @@ XML_ParserCreateNS(const XML_Char *encoding, Constructs a new parser that has namespace processing in effect. Namespace expanded element names and attribute names are returned as a concatenation of the namespace URI, sep, and the local part of the name. This -means that you should pick a character for sep that can't be -part of a legal URI.
    +means that you should pick a character for sep that can't be part +of an URI. Since Expat does not check namespace URIs for conformance, the +only safe choice for a namespace separator is a character that is illegal +in XML. For instance, '\xFF' is not legal in UTF-8, and +'\xFFFF' is not legal in UTF-16. There is a special case when +sep is the null character '\0': the namespace URI and +the local part will be concatenated without any separator - this is intended +to support RDF processors. It is a programming error to use the null separator +with namespace triplets.
    -XML_Parser
    +XML_Parser XMLCALL
     XML_ParserCreate_MM(const XML_Char *encoding,
                         const XML_Memory_Handling_Suite *ms,
     		    const XML_Char *sep);
     
     typedef struct {
    -  void *(*malloc_fcn)(size_t size);
    -  void *(*realloc_fcn)(void *ptr, size_t size);
    -  void (*free_fcn)(void *ptr);
    +  void *(XMLCALL *malloc_fcn)(size_t size);
    +  void *(XMLCALL *realloc_fcn)(void *ptr, size_t size);
    +  void (XMLCALL *free_fcn)(void *ptr);
     } XML_Memory_Handling_Suite;
     
    @@ -666,7 +957,7 @@ the namespace URI and the local part of the name.

    -XML_Parser
    +XML_Parser XMLCALL
     XML_ExternalEntityParserCreate(XML_Parser p,
                                    const XML_Char *context,
                                    const XML_Char *encoding);
    @@ -682,7 +973,7 @@ differently than the parent parser).
     
     
     
    -void
    +void XMLCALL
     XML_ParserFree(XML_Parser p);
     
    @@ -691,14 +982,17 @@ freeing any memory associated with user data.
    -XML_Bool
    -XML_ParserReset(XML_Parser p);
    +XML_Bool XMLCALL
    +XML_ParserReset(XML_Parser p,
    +                const XML_Char *encoding);
     
    Clean up the memory structures maintained by the parser so that it may be used again. After this has been called, parser is -ready to start parsing a new document. This function may not be used -on a parser created using XML_ExternalEntityParserCreate; it will return XML_FALSE in that case. Returns XML_TRUE on success. Your application is responsible for @@ -708,18 +1002,26 @@ dealing with any memory associated with user data.

    Parsing

    To state the obvious: the three parsing functions XML_Parse, XML_ParseBuffer and >XML_GetBuffer must not be -called from within a handler unless they operate on a separate parser -instance, that is, one that did not call the handler. For example, it -is OK to call the parsing functions from within an -XML_ExternalEntityRefHandler, if they apply to the parser -created by XML_Parse, +XML_ParseBuffer and +XML_GetBuffer must not be called from within a handler +unless they operate on a separate parser instance, that is, one that +did not call the handler. For example, it is OK to call the parsing +functions from within an XML_ExternalEntityRefHandler, +if they apply to the parser created by +XML_ExternalEntityParserCreate.

    +

    Note: the len argument passed to these functions +should be considerably less than the maximum value for an integer, +as it could create an integer overflow situation if the added +lengths of a buffer and the unprocessed portion of the previous buffer +exceed the maximum integer value. Input data at the end of a buffer +will remain unprocessed if it is part of an XML token for which the +end is not part of that buffer.

    +
    -XML_Status
    +enum XML_Status XMLCALL
     XML_Parse(XML_Parser p,
               const char *s,
               int len,
    @@ -746,7 +1048,7 @@ Otherwise it returns XML_STATUS_OK value.
     
    -XML_Status
    +enum XML_Status XMLCALL
     XML_ParseBuffer(XML_Parser p,
                     int len,
                     int isFinal);
    @@ -760,7 +1062,7 @@ copying of the input.
     
     
     
    -void *
    +void * XMLCALL
     XML_GetBuffer(XML_Parser p,
                   int len);
     
    @@ -794,6 +1096,127 @@ for (;;) {
    +
    +enum XML_Status XMLCALL
    +XML_StopParser(XML_Parser p,
    +               XML_Bool resumable);
    +
    +
    + +

    Stops parsing, causing XML_Parse or XML_ParseBuffer to return. Must be called from within a +call-back handler, except when aborting (when resumable +is XML_FALSE) an already suspended parser. Some +call-backs may still follow because they would otherwise get +lost, including +

      +
    • the end element handler for empty elements when stopped in the + start element handler,
    • +
    • the end namespace declaration handler when stopped in the end + element handler,
    • +
    • the character data handler when stopped in the character data handler + while making multiple call-backs on a contiguous chunk of characters,
    • +
    +and possibly others.

    + +

    This can be called from most handlers, including DTD related +call-backs, except when parsing an external parameter entity and +resumable is XML_TRUE. Returns +XML_STATUS_OK when successful, +XML_STATUS_ERROR otherwise. The possible error codes +are:

    +
    +
    XML_ERROR_SUSPENDED
    +
    when suspending an already suspended parser.
    +
    XML_ERROR_FINISHED
    +
    when the parser has already finished.
    +
    XML_ERROR_SUSPEND_PE
    +
    when suspending while parsing an external PE.
    +
    + +

    Since the stop/resume feature requires application support in the +outer parsing loop, it is an error to call this function for a parser +not being handled appropriately; see Temporarily Stopping Parsing for more information.

    + +

    When resumable is XML_TRUE then parsing +is suspended, that is, XML_Parse and XML_ParseBuffer return XML_STATUS_SUSPENDED. +Otherwise, parsing is aborted, that is, XML_Parse and XML_ParseBuffer return +XML_STATUS_ERROR with error code +XML_ERROR_ABORTED.

    + +

    Note: +This will be applied to the current parser instance only, that is, if +there is a parent parser then it will continue parsing when the +external entity reference handler returns. It is up to the +implementation of that handler to call XML_StopParser on the parent parser +(recursively), if one wants to stop parsing altogether.

    + +

    When suspended, parsing can be resumed by calling XML_ResumeParser.

    + +

    New in Expat 1.95.8.

    +
    + +
    +enum XML_Status XMLCALL
    +XML_ResumeParser(XML_Parser p);
    +
    +
    +

    Resumes parsing after it has been suspended with XML_StopParser. Must not be called from +within a handler call-back. Returns same status codes as XML_Parse or XML_ParseBuffer. An additional error +code, XML_ERROR_NOT_SUSPENDED, will be returned if the +parser was not currently suspended.

    + +

    Note: +This must be called on the most deeply nested child parser instance +first, and on its parent parser only after the child parser has +finished, to be applied recursively until the document entity's parser +is restarted. That is, the parent parser will not resume by itself +and it is up to the application to call XML_ResumeParser on it at the +appropriate moment.

    + +

    New in Expat 1.95.8.

    +
    + +
    +void XMLCALL
    +XML_GetParsingStatus(XML_Parser p,
    +                     XML_ParsingStatus *status);
    +
    +
    +enum XML_Parsing {
    +  XML_INITIALIZED,
    +  XML_PARSING,
    +  XML_FINISHED,
    +  XML_SUSPENDED
    +};
    +
    +typedef struct {
    +  enum XML_Parsing parsing;
    +  XML_Bool finalBuffer;
    +} XML_ParsingStatus;
    +
    +
    +

    Returns status of parser with respect to being initialized, +parsing, finished, or suspended, and whether the final buffer is being +processed. The status parameter must not be +NULL.

    + +

    New in Expat 1.95.8.

    +
    + +

    Handler Setting

    Although handlers are typically set prior to parsing and left alone, an @@ -808,21 +1231,23 @@ appropriate handler setter. None of the handler setting functions have a return value.

    Your handlers will be receiving strings in arrays of type -XML_Char. This type is defined in expat.h as char -* and contains bytes encoding UTF-8. Note that you'll receive -them in this form independent of the original encoding of the -document.

    +XML_Char. This type is conditionally defined in expat.h as +either char, wchar_t or unsigned short. +The former implies UTF-8 encoding, the latter two imply UTF-16 encoding. +Note that you'll receive them in this form independent of the original +encoding of the document.

    +void XMLCALL
     XML_SetStartElementHandler(XML_Parser p,
                                XML_StartElementHandler start);
     
     typedef void
    -(*XML_StartElementHandler)(void *userData,
    -                           const XML_Char *name,
    -                           const XML_Char **atts);
    +(XMLCALL *XML_StartElementHandler)(void *userData,
    +                                   const XML_Char *name,
    +                                   const XML_Char **atts);
     

    Set handler for start (and empty) tags. Attributes are passed to the start handler as a pointer to a vector of char pointers. Each attribute seen in @@ -835,13 +1260,14 @@ by a null pointer.

    +void XMLCALL
     XML_SetEndElementHandler(XML_Parser p,
                              XML_EndElementHandler);
     
     typedef void
    -(*XML_EndElementHandler)(void *userData,
    -                         const XML_Char *name);
    +(XMLCALL *XML_EndElementHandler)(void *userData,
    +                                 const XML_Char *name);
     

    Set handler for end (and empty) tags. As noted above, an empty tag generates a call to both start and end handlers.

    @@ -849,6 +1275,7 @@ generates a call to both start and end handlers.

    +void XMLCALL
     XML_SetElementHandler(XML_Parser p,
                           XML_StartElementHandler start,
                           XML_EndElementHandler end);
    @@ -858,33 +1285,38 @@ XML_SetElementHandler(XML_Parser p,
     
     
    +void XMLCALL
     XML_SetCharacterDataHandler(XML_Parser p,
                                 XML_CharacterDataHandler charhndl)
     
     typedef void
    -(*XML_CharacterDataHandler)(void *userData,
    -                            const XML_Char *s,
    -                            int len);
    +(XMLCALL *XML_CharacterDataHandler)(void *userData,
    +                                    const XML_Char *s,
    +                                    int len);
     

    Set a text handler. The string your handler receives is NOT nul-terminated. You have to use the length argument to deal with the end of the string. A single block of contiguous text free of markup may still result in a sequence of calls to this handler. In other words, if you're searching for a pattern in the text, it may -be split across calls to this handler.

    +be split across calls to this handler. Note: Setting this handler to NULL +may NOT immediately terminate call-backs if the parser is currently +processing such a single block of contiguous markup-free text, as the parser +will continue calling back until the end of the block is reached.

    +void XMLCALL
     XML_SetProcessingInstructionHandler(XML_Parser p,
                                         XML_ProcessingInstructionHandler proc)
     
     typedef void
    -(*XML_ProcessingInstructionHandler)(void *userData,
    -                                    const XML_Char *target,
    -                                    const XML_Char *data);
    +(XMLCALL *XML_ProcessingInstructionHandler)(void *userData,
    +                                            const XML_Char *target,
    +                                            const XML_Char *data);
     
     

    Set a handler for processing instructions. The target is the first word @@ -894,13 +1326,14 @@ it after skipping all whitespace after the initial word.

    +void XMLCALL
     XML_SetCommentHandler(XML_Parser p,
                           XML_CommentHandler cmnt)
     
     typedef void
    -(*XML_CommentHandler)(void *userData,
    -                      const XML_Char *data);
    +(XMLCALL *XML_CommentHandler)(void *userData,
    +                              const XML_Char *data);
     

    Set a handler for comments. The data is all text inside the comment delimiters.

    @@ -908,30 +1341,33 @@ delimiters.

    +void XMLCALL
     XML_SetStartCdataSectionHandler(XML_Parser p,
                                     XML_StartCdataSectionHandler start);
     
     typedef void
    -(*XML_StartCdataSectionHandler)(void *userData);
    +(XMLCALL *XML_StartCdataSectionHandler)(void *userData);
     

    Set a handler that gets called at the beginning of a CDATA section.

    +void XMLCALL
     XML_SetEndCdataSectionHandler(XML_Parser p,
                                   XML_EndCdataSectionHandler end);
     
     typedef void
    -(*XML_EndCdataSectionHandler)(void *userData);
    +(XMLCALL *XML_EndCdataSectionHandler)(void *userData);
     

    Set a handler that gets called at the end of a CDATA section.

    +void XMLCALL
     XML_SetCdataSectionHandler(XML_Parser p,
                                XML_StartCdataSectionHandler start,
                                XML_EndCdataSectionHandler end)
    @@ -941,14 +1377,15 @@ XML_SetCdataSectionHandler(XML_Parser p,
     
     
    +void XMLCALL
     XML_SetDefaultHandler(XML_Parser p,
                           XML_DefaultHandler hndl)
     
     typedef void
    -(*XML_DefaultHandler)(void *userData,
    -                      const XML_Char *s,
    -                      int len);
    +(XMLCALL *XML_DefaultHandler)(void *userData,
    +                              const XML_Char *s,
    +                              int len);
     

    Sets a handler for any characters in the document which wouldn't @@ -971,14 +1408,15 @@ href="#XML_DefaultCurrent">XML_DefaultCurrent.

    +void XMLCALL
     XML_SetDefaultHandlerExpand(XML_Parser p,
                                 XML_DefaultHandler hndl)
     
     typedef void
    -(*XML_DefaultHandler)(void *userData,
    -                      const XML_Char *s,
    -                      int len);
    +(XMLCALL *XML_DefaultHandler)(void *userData,
    +                              const XML_Char *s,
    +                              int len);
     

    This sets a default handler, but doesn't inhibit the expansion of internal entity references. The entity reference will not be passed @@ -990,16 +1428,17 @@ href="#XML_DefaultCurrent">XML_DefaultCurrent.

    +void XMLCALL
     XML_SetExternalEntityRefHandler(XML_Parser p,
                                     XML_ExternalEntityRefHandler hndl)
     
     typedef int
    -(*XML_ExternalEntityRefHandler)(XML_Parser p,
    -                                const XML_Char *context,
    -                                const XML_Char *base,
    -                                const XML_Char *systemId,
    -                                const XML_Char *publicId);
    +(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser p,
    +                                        const XML_Char *context,
    +                                        const XML_Char *base,
    +                                        const XML_Char *systemId,
    +                                        const XML_Char *publicId);
     

    Set an external entity reference handler. This handler is also called for processing an external DTD subset if parameter entity parsing @@ -1042,6 +1481,7 @@ information into global or static variables.

    +void XMLCALL
     XML_SetExternalEntityRefHandlerArg(XML_Parser p,
                                        void *arg)
     
    @@ -1067,14 +1507,15 @@ properly.

    +void XMLCALL
     XML_SetSkippedEntityHandler(XML_Parser p,
                                 XML_SkippedEntityHandler handler)
     
     typedef void
    -(*XML_SkippedEntityHandler)(void *userData,
    -                            const XML_Char *entityName,
    -                            int is_parameter_entity);
    +(XMLCALL *XML_SkippedEntityHandler)(void *userData,
    +                                    const XML_Char *entityName,
    +                                    int is_parameter_entity);
     

    Set a skipped entity handler. This is called in two situations:

      @@ -1093,21 +1534,22 @@ sync with the reporting of the declarations or attribute values

      +void XMLCALL
       XML_SetUnknownEncodingHandler(XML_Parser p,
                                     XML_UnknownEncodingHandler enchandler,
       			      void *encodingHandlerData)
       
       typedef int
      -(*XML_UnknownEncodingHandler)(void *encodingHandlerData,
      -                              const XML_Char *name,
      -                              XML_Encoding *info);
      +(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
      +                                      const XML_Char *name,
      +                                      XML_Encoding *info);
       
       typedef struct {
         int map[256];
         void *data;
      -  int (*convert)(void *data, const char *s);
      -  void (*release)(void *data);
      +  int (XMLCALL *convert)(void *data, const char *s);
      +  void (XMLCALL *release)(void *data);
       } XML_Encoding;
       

      Set a handler to deal with encodings other than the built in set. This should be done before "#XML_ParseBuffer" >XML_ParseBuffer have been called on the given parser.

      If the handler knows how to deal with an encoding with the given name, it should fill in the info data -structure and return XML_STATUS_ERROR. Otherwise it -should return XML_STATUS_OK. The handler will be called +structure and return XML_STATUS_OK. Otherwise it +should return XML_STATUS_ERROR. The handler will be called at most once per parsed (external) entity. The optional application data pointer encodingHandlerData will be passed back to the handler.

      @@ -1141,76 +1583,61 @@ parser when it is finished with the encoding. It may be NULL.

      +void XMLCALL
       XML_SetStartNamespaceDeclHandler(XML_Parser p,
       			         XML_StartNamespaceDeclHandler start);
       
       typedef void
      -(*XML_StartNamespaceDeclHandler)(void *userData,
      -                                 const XML_Char *prefix,
      -                                 const XML_Char *uri);
      +(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData,
      +                                         const XML_Char *prefix,
      +                                         const XML_Char *uri);
       

      Set a handler to be called when a namespace is declared. Namespace declarations occur inside start tags. But the namespace declaration start handler is called before the start tag handler for each namespace declared in that start tag.

      - -

      Note: -Due to limitations of the implementation, the -StartNamespaceDeclHandler is not called unless the StartElementHandler -is also set. The specific value of the StartElementHandler is allowed -to change freely, so long as it is not NULL.

      +void XMLCALL
       XML_SetEndNamespaceDeclHandler(XML_Parser p,
       			       XML_EndNamespaceDeclHandler end);
       
       typedef void
      -(*XML_EndNamespaceDeclHandler)(void *userData,
      -                               const XML_Char *prefix);
      +(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData,
      +                                       const XML_Char *prefix);
       

      Set a handler to be called when leaving the scope of a namespace declaration. This will be called, for each namespace declaration, after the handler for the end tag of the element in which the namespace was declared.

      - -

      Note: -Due to limitations of the implementation, the EndNamespaceDeclHandler -is not called unless the StartElementHandler is also set. The -specific value of the StartElementHandler is allowed to change freely, -so long as it is not NULL.

      +void XMLCALL
       XML_SetNamespaceDeclHandler(XML_Parser p,
                                   XML_StartNamespaceDeclHandler start,
                                   XML_EndNamespaceDeclHandler end)
       

      Sets both namespace declaration handlers with a single call.

      - -

      Note: -Due to limitations of the implementation, the -StartNamespaceDeclHandler and EndNamespaceDeclHandler are not called -unless the StartElementHandler is also set. The specific value of the -StartElementHandler is allowed to change freely, so long as it is not -NULL.

      +void XMLCALL
       XML_SetXmlDeclHandler(XML_Parser p,
       		      XML_XmlDeclHandler xmldecl);
       
       typedef void
      -(*XML_XmlDeclHandler) (void            *userData,
      -                       const XML_Char  *version,
      -                       const XML_Char  *encoding,
      -                       int             standalone);
      +(XMLCALL *XML_XmlDeclHandler)(void            *userData,
      +                              const XML_Char  *version,
      +                              const XML_Char  *encoding,
      +                              int             standalone);
       

      Sets a handler that is called for XML declarations and also for text declarations discovered in external entities. The way to @@ -1224,16 +1651,17 @@ that it was given as yes.

      +void XMLCALL
       XML_SetStartDoctypeDeclHandler(XML_Parser p,
       			       XML_StartDoctypeDeclHandler start);
       
       typedef void
      -(*XML_StartDoctypeDeclHandler)(void           *userData,
      -                               const XML_Char *doctypeName,
      -                               const XML_Char *sysid,
      -                               const XML_Char *pubid,
      -                               int            has_internal_subset);
      +(XMLCALL *XML_StartDoctypeDeclHandler)(void           *userData,
      +                                       const XML_Char *doctypeName,
      +                                       const XML_Char *sysid,
      +                                       const XML_Char *pubid,
      +                                       int            has_internal_subset);
       

      Set a handler that is called at the start of a DOCTYPE declaration, before any external or internal subset is parsed. Both sysid @@ -1243,12 +1671,13 @@ will be non-zero if the DOCTYPE declaration has an internal subset.

      +void XMLCALL
       XML_SetEndDoctypeDeclHandler(XML_Parser p,
       			     XML_EndDoctypeDeclHandler end);
       
       typedef void
      -(*XML_EndDoctypeDeclHandler)(void *userData);
      +(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
       

      Set a handler that is called at the end of a DOCTYPE declaration, after parsing any external subset.

      @@ -1256,6 +1685,7 @@ after parsing any external subset.

      +void XMLCALL
       XML_SetDoctypeDeclHandler(XML_Parser p,
       			  XML_StartDoctypeDeclHandler start,
       			  XML_EndDoctypeDeclHandler end);
      @@ -1265,14 +1695,15 @@ XML_SetDoctypeDeclHandler(XML_Parser p,
       
       
      +void XMLCALL
       XML_SetElementDeclHandler(XML_Parser p,
       			  XML_ElementDeclHandler eldecl);
       
       typedef void
      -(*XML_ElementDeclHandler)(void *userData,
      -                          const XML_Char *name,
      -                          XML_Content *model);
      +(XMLCALL *XML_ElementDeclHandler)(void *userData,
      +                                  const XML_Char *name,
      +                                  XML_Content *model);
       
       enum XML_Content_Type {
      @@ -1336,17 +1767,18 @@ or sequence and children points to the nodes.

      +void XMLCALL
       XML_SetAttlistDeclHandler(XML_Parser p,
                                 XML_AttlistDeclHandler attdecl);
       
       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);
      +(XMLCALL *XML_AttlistDeclHandler)(void           *userData,
      +                                  const XML_Char *elname,
      +                                  const XML_Char *attname,
      +                                  const XML_Char *att_type,
      +                                  const XML_Char *dflt,
      +                                  int            isrequired);
       

      Set a handler for attlist declarations in the DTD. This handler is called for each attribute. So a single attlist declaration @@ -1368,20 +1800,21 @@ in the dflt parameter.

      +void XMLCALL
       XML_SetEntityDeclHandler(XML_Parser p,
       			 XML_EntityDeclHandler handler);
       
       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);
      +(XMLCALL *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);
       

      Sets a handler that will be called for all entity declarations. The is_parameter_entity argument will be non-zero in the @@ -1401,17 +1834,18 @@ declarations.

      +void XMLCALL
       XML_SetUnparsedEntityDeclHandler(XML_Parser p,
                                        XML_UnparsedEntityDeclHandler h)
       
       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);
      +(XMLCALL *XML_UnparsedEntityDeclHandler)(void *userData,
      +                                         const XML_Char *entityName, 
      +                                         const XML_Char *base,
      +                                         const XML_Char *systemId,
      +                                         const XML_Char *publicId,
      +                                         const XML_Char *notationName);
       

      Set a handler that receives declarations of unparsed entities. These are entity declarations that have a notation (NDATA) field:

      @@ -1426,28 +1860,30 @@ compatibility. Use instead
      +void XMLCALL
       XML_SetNotationDeclHandler(XML_Parser p,
                                  XML_NotationDeclHandler h)
       
       typedef void
      -(*XML_NotationDeclHandler)(void *userData,
      -                           const XML_Char *notationName,
      -                           const XML_Char *base,
      -                           const XML_Char *systemId,
      -                           const XML_Char *publicId);
      +(XMLCALL *XML_NotationDeclHandler)(void *userData, 
      +                                   const XML_Char *notationName,
      +                                   const XML_Char *base,
      +                                   const XML_Char *systemId,
      +                                   const XML_Char *publicId);
       

      Set a handler that receives notation declarations.

      +void XMLCALL
       XML_SetNotStandaloneHandler(XML_Parser p,
                                   XML_NotStandaloneHandler h)
       
       typedef int 
      -(*XML_NotStandaloneHandler)(void *userData);
      +(XMLCALL *XML_NotStandaloneHandler)(void *userData);
       

      Set a handler that is called if the document is not "standalone". This happens when there is an external subset or a reference to a @@ -1461,18 +1897,22 @@ error.

      These are the functions you'll want to call when the parse functions return XML_STATUS_ERROR (a parse error has -ocurred), although the position reporting functions are useful outside +occurred), although the position reporting functions are useful outside of errors. The position reported is the byte position (in the original document or entity encoding) of the first of the sequence of characters that generated the current event (or the error that caused -the parse functions to return XML_STATUS_ERROR.)

      +the parse functions to return XML_STATUS_ERROR.) The +exceptions are callbacks trigged by declarations in the document +prologue, in which case they exact position reported is somewhere in the +relevant markup, but not necessarily as meaningful as for other +events.

      The position reporting functions are accurate only outside of the DTD. In other words, they usually return bogus information when called from within a DTD declaration handler.

      -enum XML_Error
      +enum XML_Error XMLCALL
       XML_GetErrorCode(XML_Parser p);
       
      @@ -1480,8 +1920,8 @@ Return what type of error has occurred.
      -const XML_LChar *
      -XML_ErrorString(int code);
      +const XML_LChar * XMLCALL
      +XML_ErrorString(enum XML_Error code);
       
      Return a string describing the error corresponding to code. @@ -1490,23 +1930,27 @@ The code should be one of the enums that can be returned from
      -long
      +XML_Index XMLCALL
       XML_GetCurrentByteIndex(XML_Parser p);
       
      -int
      +XML_Size XMLCALL
       XML_GetCurrentLineNumber(XML_Parser p);
       
      -Return the line number of the position. +Return the line number of the position. The first line is reported as +1.
      -int
      +XML_Size XMLCALL
       XML_GetCurrentColumnNumber(XML_Parser p);
       
      @@ -1515,7 +1959,7 @@ the position.
      -int
      +int XMLCALL
       XML_GetCurrentByteCount(XML_Parser p);
       
      @@ -1527,7 +1971,7 @@ separate start and end tags).
      -const char *
      +const char * XMLCALL
       XML_GetInputContext(XML_Parser p,
                           int *offset,
                           int *size);
      @@ -1547,6 +1991,9 @@ untranslated bytes of the input.

      Only a limited amount of context is kept, so if the event triggering a call spans over a very large amount of input, the actual parse position may be before the beginning of the buffer.

      + +

      If XML_CONTEXT_BYTES is not defined, this will always +return NULL.

      Miscellaneous functions

      @@ -1555,7 +2002,7 @@ parse position may be before the beginning of the buffer.

      the parser or can be used to dynamicly set parser options.

      -void
      +void XMLCALL
       XML_SetUserData(XML_Parser p,
                       void *userData);
       
      @@ -1570,7 +2017,7 @@ memory.
      -void *
      +void * XMLCALL
       XML_GetUserData(XML_Parser p);
       
      @@ -1579,7 +2026,7 @@ It is actually implemented as a macro.
      -void
      +void XMLCALL
       XML_UseParserAsHandlerArg(XML_Parser p);
       
      -const XML_Char *
      +const XML_Char * XMLCALL
       XML_GetBase(XML_Parser p);
       
      @@ -1610,7 +2057,7 @@ Return the base for resolving relative URIs.
      -int
      +int XMLCALL
       XML_GetSpecifiedAttributeCount(XML_Parser p);
       
      @@ -1626,7 +2073,7 @@ means the current call.
      -int
      +int XMLCALL
       XML_GetIdAttributeIndex(XML_Parser p);
       
      @@ -1637,8 +2084,29 @@ attribute. If called inside a start handler, then that means the current call.
      +
      +const XML_AttrInfo * XMLCALL
      +XML_GetAttributeInfo(XML_Parser parser);
      +
      +
      +typedef struct {
      +  XML_Index  nameStart;  /* Offset to beginning of the attribute name. */
      +  XML_Index  nameEnd;    /* Offset after the attribute name's last byte. */
      +  XML_Index  valueStart; /* Offset to beginning of the attribute value. */
      +  XML_Index  valueEnd;   /* Offset after the attribute value's last byte. */
      +} XML_AttrInfo;
      +
      +
      +Returns an array of XML_AttrInfo structures for the +attribute/value pairs passed in the last call to the +XML_StartElementHandler that were specified +in the start-tag rather than defaulted. Each attribute/value pair counts +as 1; thus the number of entries in the array is +XML_GetSpecifiedAttributeCount(parser) / 2. +
      +
      -enum XML_Status
      +enum XML_Status XMLCALL
       XML_SetEncoding(XML_Parser p,
                       const XML_Char *encoding);
       
      @@ -1653,7 +2121,7 @@ Returns XML_STATUS_OK on success or
      -int
      +int XMLCALL
       XML_SetParamEntityParsing(XML_Parser p,
                                 enum XML_ParamEntityParsing code);
       
      @@ -1667,10 +2135,28 @@ The choices for code are:
    1. XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE
    2. XML_PARAM_ENTITY_PARSING_ALWAYS
    3. +Note: If XML_SetParamEntityParsing is called after +XML_Parse or XML_ParseBuffer, then it has +no effect and will always return 0. +
      + +
      +int XMLCALL
      +XML_SetHashSalt(XML_Parser p,
      +                unsigned long hash_salt);
      +
      +
      +Sets the hash salt to use for internal hash calculations. +Helps in preventing DoS attacks based on predicting hash +function behavior. In order to have an effect this must be called +before parsing has started. Returns 1 if successful, 0 when called +after XML_Parse or XML_ParseBuffer. +

      Note: This call is optional, as the parser will auto-generate a new +random salt value if no value has been set at the start of parsing.

      -enum XML_Error
      +enum XML_Error XMLCALL
       XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
       
      -void
      +void XMLCALL
       XML_SetReturnNSTriplet(XML_Parser parser,
                              int        do_nst);
       
      @@ -1724,7 +2215,7 @@ separator.

      -void
      +void XMLCALL
       XML_DefaultCurrent(XML_Parser parser);
       
      @@ -1738,7 +2229,7 @@ not a default handler.
      -XML_LChar *
      +XML_LChar * XMLCALL
       XML_ExpatVersion();
       
      @@ -1746,7 +2237,7 @@ Return the library version as a string (e.g. "expat_1.95.1").
      -struct XML_Expat_Version
      +struct XML_Expat_Version XMLCALL
       XML_ExpatVersionInfo();
       
      @@ -1770,7 +2261,7 @@ particular parts of the Expat API are available.
       
      -const XML_Feature *
      +const XML_Feature * XMLCALL
       XML_GetFeatureList();
       
      @@ -1782,7 +2273,9 @@ enum XML_FeatureEnum {
         XML_FEATURE_CONTEXT_BYTES,
         XML_FEATURE_MIN_SIZE,
         XML_FEATURE_SIZEOF_XML_CHAR,
      -  XML_FEATURE_SIZEOF_XML_LCHAR
      +  XML_FEATURE_SIZEOF_XML_LCHAR,
      +  XML_FEATURE_NS,
      +  XML_FEATURE_LARGE_SIZE
       };
       
       typedef struct {
      @@ -1829,7 +2322,7 @@ time, the following features have been defined to have values:

      -void
      +void XMLCALL
       XML_FreeContentModel(XML_Parser parser, XML_Content *model);