From commits-return-11512-apmail-apr-commits-archive=apr.apache.org@apr.apache.org Wed Sep 29 10:00:04 2010 Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 94021 invoked from network); 29 Sep 2010 10:00:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Sep 2010 10:00:01 -0000 Received: (qmail 38569 invoked by uid 500); 29 Sep 2010 10:00:00 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 38376 invoked by uid 500); 29 Sep 2010 09:59:58 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 38306 invoked by uid 99); 29 Sep 2010 09:59:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Sep 2010 09:59:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Sep 2010 09:59:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4ACAC2388B45; Wed, 29 Sep 2010 09:59:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1002549 [7/14] - in /apr/apr-util/vendor/expat/current: ./ bcb5/ conftools/ doc/ examples/ lib/ tests/ vms/ win32/ xmlwf/ Date: Wed, 29 Sep 2010 09:59:07 -0000 To: commits@apr.apache.org From: jorton@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100929095909.4ACAC2388B45@eris.apache.org> Modified: apr/apr-util/vendor/expat/current/doc/reference.html URL: http://svn.apache.org/viewvc/apr/apr-util/vendor/expat/current/doc/reference.html?rev=1002549&r1=1002548&r2=1002549&view=diff ============================================================================== --- apr/apr-util/vendor/expat/current/doc/reference.html (original) +++ apr/apr-util/vendor/expat/current/doc/reference.html Wed Sep 29 09:59:04 2010 @@ -1,174 +1,202 @@ - + + - Expat XML Parser - - - + + + -

Expat XML Parser

- -

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 -XML::Parser, and other open-source XML parsers.

+ + + + + + + + + +
(Expat logo)
Release 1.95.7
+
+ +

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 +XML::Parser, Python's xml.parsers.expat, and +other open-source XML parsers.

This library is the creation of James Clark, who's also given us -groff (an nroff look-alike), Jade (an implemention of ISO's DSSSL stylesheet -language for SGML), XP (a Java XML parser package), XT (a Java XSL engine). -James was also the technical lead on the XML Working Group at W3 that produced -the XML specification.

- -

This is free software, licensed under the -MIT/X Consortium license. You may download it from -the expat homepage on Source Forge. +groff (an nroff look-alike), Jade (an implemention of ISO's DSSSL +stylesheet language for SGML), XP (a Java XML parser package), XT (a +Java XSL engine). James was also the technical lead on the XML +Working Group at W3C that produced the XML specification.

+ +

This is free software, licensed under the 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 me 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

-
+

Overview

-

Expat is a stream-oriented parser. You register callback (or handler) -functions with -the parser and then start feeding it the document. -As the parser recognizes parts of -the document, it will call the appropriate handler for that part (if you've -registered one.) The document is fed to the parser in pieces, so you can -start parsing before you have all the document. This also allows you to -parse really huge documents that won't fit into memory.

- -

Expat can be intimidating due to the many kinds of handlers and options -you can set. But you only need to learn four functions in order to do 90% -of what you'll want to do with it:

+ +

Expat is a stream-oriented parser. You register callback (or +handler) functions with the parser and then start feeding it the +document. As the parser recognizes parts of the document, it will +call the appropriate handler for that part (if you've registered one.) +The document is fed to the parser in pieces, so you can start parsing +before you have all the document. This also allows you to parse really +huge documents that won't fit into memory.

+ +

Expat can be intimidating due to the many kinds of handlers and +options you can set. But you only need to learn four functions in +order to do 90% of what you'll want to do with it:

-
XML_ParserCreate
+
XML_ParserCreate
Create a new parser object.
-
XML_SetElementHandler
+
XML_SetElementHandler
Set handlers for start and end tags.
-
XML_SetCharacterDataHandler
+
XML_SetCharacterDataHandler
Set handler for text.
-
XML_Parse
+
XML_Parse
Pass a buffer full of document to the parser
-

These functions and others are described in the -reference part of this document. The reference -section also describes in detail the parameters passed to the different -types of handlers. - -

Let's look at a very simple example program that only uses 3 of the above -functions (it doesn't need to set a character handler.) The program -outline.c -prints an element outline, indenting child elements to distinguish them from -the parent element that contains them. The start handler does all the work. -It prints two indenting spaces for every level of ancestor elements, then -it prints the element and attribute information. Finally it increments the -global Depth variable. +

These functions and others are described in the reference part of this document. The reference +section also describes in detail the parameters passed to the +different types of handlers.

+ +

Let's look at a very simple example program that only uses 3 of the +above functions (it doesn't need to set a character handler.) The +program outline.c prints an +element outline, indenting child elements to distinguish them from the +parent element that contains them. The start handler does all the +work. It prints two indenting spaces for every level of ancestor +elements, then it prints the element and attribute +information. Finally it increments the global Depth +variable.

-
-
+
 int Depth;
 
-void
+void XMLCALL
 start(void *data, const char *el, const char **attr) {
   int i;
 
@@ -185,98 +213,181 @@ start(void *data, const char *el, const 
   Depth++;
 }  /* End of start handler */
 
-
-

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

-
-void
+

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

+
+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. +shoveling the document to the parser so that it can do its work.

+ +
+

Building and Installing Expat

-
-

Building and Installing expat

-

The expat distribution comes as a compressed (with GNU gzip) tar file. -You may download the latest version from -Source Forge. -After unpacking this, cd into the directory. Then follow either the -Win32 directions or Unix directions below.

+

The Expat distribution comes as a compressed (with GNU gzip) tar +file. You may download the latest version from Source Forge. After +unpacking this, cd into the directory. Then follow either the Win32 +directions or Unix directions below.

Building under Win32

-

If you're using the GNU compiler under cygwin, follow the Unix directions -in the next section. Otherwise if you have Microsoft's Developer Studio -installed, then from Windows Explorer double-click on "expat.dsp" in the -lib directory and build and install in the usual manner.

-

Alternatively, you may download the win32 binary package that contains -the expat.h include file and a pre-built dll.

+

If you're using the GNU compiler under cygwin, follow the Unix +directions in the next section. Otherwise if you have Microsoft's +Developer Studio installed, then from Windows Explorer double-click on +"expat.dsp" in the lib directory and build and install in the usual +manner.

+ +

Alternatively, you may download the Win32 binary package that +contains the "expat.h" include file and a pre-built DLL.

Building under Unix (or GNU)

-

First you'll need to run the configure shell script in order to configure -the Makefiles and headers for your system.

+ +

First you'll need to run the configure shell script in order to +configure the Makefiles and headers for your system.

If you're happy with all the defaults that configure picks for you, -and you have permission on your system to install into /usr/local, you can -install expat with this sequence of commands:

+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 -only one we'll mention here is the --prefix option. You can -find out all the options available by running configure with just the ---help option. -

- -By default, the configure script sets things up so that the library gets -installed in /usr/local/lib and the associated header file in -/usr/local/include. -But if you were to give the option, --prefix=/home/me/mystuff, -then the library and header would get installed in -/home/me/mystuff/lib and /home/me/mystuff/include -respectively. -

+only one we'll mention here is the --prefix option. You +can find out all the options available by running configure with just +the --help option.

+ +

By default, the configure script sets things up so that the library +gets installed in /usr/local/lib and the associated +header file in /usr/local/include. But if you were to +give the option, --prefix=/home/me/mystuff, then the +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 the DTD are reported +and attribute value normalization occurs based on the type of +attributes. Callbacks can be registered which report information from +the DTD (including content models and attribute definitions) only if +this is defined. Without this, Expat has a smaller memory footprint +and can be faster.
+ +
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_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. 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.
+
-
+

Using Expat

-

Compiling and Linking against expat

-

Unless you installed expat in a location not expected by your compiler -and linker, all you have to do to use expat in your programs is to include -the expat header (#include <expat.h>) in your files that -make calls to it and to tell the linker -that it needs to link against the expat library. On Unix systems, this would -be 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 run time. -

-

On a Unix based system, here's what a Makefile might look like when expat -is installed in a standard location:

-
-
+

Compiling and Linking Against Expat

+ +

Unless you installed Expat in a location not expected by your +compiler and linker, all you have to do to use Expat in your programs +is to include the Expat header (#include <expat.h>) +in your files that make calls to it and to tell the linker that it +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 +run time.

+ +

On a Unix-based system, here's what a Makefile might look like when +Expat is installed in a standard location:

+ +
 CC=cc
 LDFLAGS=
 LIBS= -lexpat
 xmlapp: xmlapp.o
         $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS)
 
-
-

If you installed expat in, say, /home/me/mystuff, then +

If you installed Expat in, say, /home/me/mystuff, then the Makefile would look like this:

-
-
+
 CC=cc
 CFLAGS= -I/home/me/mystuff/include
 LDFLAGS=
@@ -284,62 +395,61 @@ LIBS= -L/home/me/mystuff/lib -lexpat
 xmlapp: xmlapp.o
         $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS)
 
-
-

You'd also have to set the environment variable LD_LIBRARY_PATH -to /home/me/mystuff/lib (or to -${LD_LIBRARY_PATH}:/home/me/mystuff/lib if LD_LIBRARY_PATH -already has some directories in it) in order to run your application. -

+

You'd also have to set the environment variable +LD_LIBRARY_PATH to /home/me/mystuff/lib (or +to ${LD_LIBRARY_PATH}:/home/me/mystuff/lib if +LD_LIBRARY_PATH already has some directories in it) in order to run +your application.

Expat Basics

-

As we saw in the example in the overview, the first step in parsing an -XML document with expat is to create a parser object. There are -three functions in the expat API for creating a -parser object. -However, only two of these -(XML_ParserCreate and -XML_ParserCreateNS) -can be used for constructing a parser for a top-level document. -The object returned 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 parser, then your application is responsible for freeing it prior to -calling XML_ParserFree. -

+ +

As we saw in the example in the overview, the first step in parsing +an XML document with Expat is to create a parser object. There are three functions in the Expat API for creating a +parser object. However, only two of these (XML_ParserCreate and XML_ParserCreateNS) can be used for +constructing a parser for a top-level document. The object returned +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 +parser, then your application is responsible for freeing it prior to +calling XML_ParserFree.

The objects returned by the parser creation functions are good for -parsing only one XML document or external parsed entity. If your application -needs to parse many XML documents, then it needs to create a parser object -for each one. The best way to deal with this is to create a higher level -object that contains all the default initialization you want for your parser -objects. - -

Walking through a document hierarchy with a stream oriented parser will -require a good stack mechanism in order to keep track of current context. -For instance, to answer the simple question, -"What element does this text belong to?" requires a stack, since the -parser may have descended into other elements that are children of the -current one and has encountered this text on the way out. - -

The things you're likely to want to keep on a stack are the currently -opened element and it's attributes. You push this information onto the -stack in the start handler and you pop it off in the end handler. - -

For some tasks, it is sufficient to just keep information on what the -depth of the stack is (or would be if you had one.) The outline program shown -above presents one example. Another such task would be skipping over a -complete element. When you see the start tag for the element you want to -skip, you set a skip flag and record the depth at which the element started. -When the end tag handler encounters the same depth, the skipped element has -ended and the flag may be cleared. If you follow the convention that the -root element starts at 1, then you can use the same variable for skip flag -and skip depth. +parsing only one XML document or external parsed entity. If your +application needs to parse many XML documents, then it needs to create +a parser object for each one. The best way to deal with this is to +create a higher level object that contains all the default +initialization you want for your parser objects.

+ +

Walking through a document hierarchy with a stream oriented parser +will require a good stack mechanism in order to keep track of current +context. For instance, to answer the simple question, "What element +does this text belong to?" requires a stack, since the parser may have +descended into other elements that are children of the current one and +has encountered this text on the way out.

+ +

The things you're likely to want to keep on a stack are the +currently opened element and it's attributes. You push this +information onto the stack in the start handler and you pop it off in +the end handler.

+ +

For some tasks, it is sufficient to just keep information on what +the depth of the stack is (or would be if you had one.) The outline +program shown above presents one example. Another such task would be +skipping over a complete element. When you see the start tag for the +element you want to skip, you set a skip flag and record the depth at +which the element started. When the end tag handler encounters the +same depth, the skipped element has ended and the flag may be +cleared. If you follow the convention that the root element starts at +1, then you can use the same variable for skip flag and skip +depth.

-
-
+
 void
 init_info(Parseinfo *info) {
   info->skip = 0;
@@ -347,7 +457,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;
 
@@ -362,7 +472,7 @@ rawstart(void *data, const char *el, con
   inf->depth++;
 }  /* End of rawstart */
 
-void
+void XMLCALL
 rawend(void *data, const char *el) {
   Parseinfo *inf = (Parseinfo *) data;
 
@@ -374,119 +484,159 @@ rawend(void *data, const char *el) {
   if (inf->skip == inf->depth)
     inf->skip = 0;
 }  /* End rawend */
-
 
-
-

Notice in the above example the difference in how depth is manipulated -in the start and end handlers. The end tag handler should be the mirror -image of the start tag handler. This is necessary to properly model -containment. Since, in the start tag handler, we -incremented depth after the main body of start tag code, then in -the end handler, we need to manipulate it before the main body. -If we'd decided to increment it first thing in the start handler, then -we'd have had to decrement it last thing in the end handler. +

Notice in the above example the difference in how depth is +manipulated in the start and end handlers. The end tag handler should +be the mirror image of the start tag handler. This is necessary to +properly model containment. Since, in the start tag handler, we +incremented depth after the main body of start tag code, then +in the end handler, we need to manipulate it before the main +body. If we'd decided to increment it first thing in the start +handler, then we'd have had to decrement it last thing in the end +handler.

-

Communicating between handlers

+

Communicating between handlers

In order to be able to pass information between different handlers 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. +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.

+ +

XML Version

+ +

Expat is an XML 1.0 parser, and as such never complains based on +the value of the version pseudo-attribute in the XML +declaration, if present.

+ +

If an application needs to check the version number (to support +alternate processing), it should use the XML_SetXmlDeclHandler function to +set a handler that uses the information in the XML declaration to +determine what to do. This example shows how to check that only a +version number of "1.0" is accepted:

+ +
+static int wrong_version;
+static XML_Parser parser;
+
+static void XMLCALL
+xmldecl_handler(void            *userData,
+                const XML_Char  *version,
+                const XML_Char  *encoding,
+                int              standalone)
+{
+  static const XML_Char Version_1_0[] = {'1', '.', '0', 0};
+
+  int i;
+
+  for (i = 0; i < (sizeof(Version_1_0) / sizeof(Version_1_0[0])); ++i) {
+    if (version[i] != Version_1_0[i]) {
+      wrong_version = 1;
+      /* also clear all other handlers: */
+      XML_SetCharacterDataHandler(parser, NULL);
+      ...
+      return;
+    }
+  }
+  ...
+}
+

Namespace Processing

-

When the parser is created using the XML_ParserCreateNS, -function, expat performs namespace processing. Under namespace processing, -expat consumes xmlns and xmlns:... attributes, +

When the parser is created using the XML_ParserCreateNS, function, Expat +performs namespace processing. Under namespace processing, Expat +consumes xmlns and xmlns:... attributes, which declare namespaces for the scope of the element in which they -occur. This means that your start handler will not see these attributes. -Your application can still be informed of these declarations by setting -namespace declaration handlers with - -XML_SetNamespaceDeclHandler. - -

Element type and attribute names that belong to a given namespace are -passed to the appropriate handler in expanded form. By default 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, and unprefixed -element names are only expanded when they are in the scope of a default -namespace. - -

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, separator, prefix. -

- -

You can set handlers for the start of a namespace declaration and 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 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. -The URI will be null for the case where the default namespace is being unset. -The namespace end handler just gets the prefix for the closing scope. - -

These handlers are called for each declaration. So if, for instance, a -start tag had three namespace declarations, then the StartNamespaceDeclHandler -would be called three times before the start tag handler is called, once for -each declaration. - -

The namespace.c example demonstrates the -use of these features. Like outline.c, it produces an outline, but -in addition it annotates when a namespace scope starts and when it ends. -This example also demonstrates use of application user data. +occur. This means that your start handler will not see these +attributes. Your application can still be informed of these +declarations by setting namespace declaration handlers with XML_SetNamespaceDeclHandler.

+ +

Element type and attribute names that belong to a given namespace +are passed to the appropriate handler in expanded form. By default +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, +and unprefixed element names are only expanded when they are in the +scope of a default namespace.

+ +

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, +separator, prefix.

+ +

You can set handlers for the start of a namespace declaration and +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 +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. +The URI will be null for the case where the default namespace is being +unset. The namespace end handler just gets the prefix for the closing +scope.

+ +

These handlers are called for each declaration. So if, for +instance, a start tag had three namespace declarations, then the +StartNamespaceDeclHandler would be called three times before the start +tag handler is called, once for each declaration.

Character Encodings

-

While XML is based on Unicode, and every XML processor is required to -recognized UTF-8 and UTF-16 (1 and 2 byte encodings of Unicode), other -encodings may be declared in XML documents or entities. For the main -document, an XML declaration may contain an encoding declaration: +

While XML is based on Unicode, and every XML processor is required +to recognized UTF-8 and UTF-16 (1 and 2 byte encodings of Unicode), +other encodings may be declared in XML documents or entities. For the +main document, an XML declaration may contain an encoding +declaration:

 <?xml version="1.0" encoding="ISO-8859-2"?>
 

External parsed entities may begin with a text declaration, which -looks like an XML declaration with just an encoding declaration: +looks like an XML declaration with just an encoding declaration:

 <?xml encoding="Big5"?>
 
-

With expat, you may also specify an encoding at the time of creating a -parser. This is useful when the encoding information may come from a source -outside the document itself (like a higher level protocol.) +

With Expat, you may also specify an encoding at the time of +creating a parser. This is useful when the encoding information may +come from a source outside the document itself (like a higher level +protocol.)

-

There are four built-in encodings in expat: +

There are four built-in encodings +in Expat:

    -
  • UTF-8 -
  • UTF-16 -
  • ISO-8859-1 -
  • US-ASCII +
  • UTF-8
  • +
  • UTF-16
  • +
  • ISO-8859-1
  • +
  • US-ASCII

Anything else discovered in an encoding declaration or in the protocol encoding specified in the parser constructor, triggers a call to the UnknownEncodingHandler. This handler gets passed the encoding name and a pointer to an XML_Encoding data -structure. Your handler must fill in this structure and return 1 if -it knows how to deal with the encoding. Otherwise the handler should -return 0. -The handler also gets passed a pointer to an -optional application data structure that you may indicate when you set -the handler. - -

Expat places restrictions on character encodings that it can support -by filling in the XML_Encoding structure. -include file: +structure. Your handler must fill in this structure and return +XML_STATUS_OK if it knows how to deal with the +encoding. Otherwise the handler should return +XML_STATUS_ERROR. The handler also gets passed a pointer +to an optional application data structure that you may indicate when +you set the handler.

+ +

Expat places restrictions on character encodings that it can +support by filling in the XML_Encoding structure. +include file:

  1. Every ASCII character that can appear in a well-formed XML document must be represented by a single byte, and that byte must correspond to @@ -499,44 +649,48 @@ for UTF-16 and UTF-8
  2. bytes
-

XML_Encoding contains an array of integers that correspond -to the 1st byte of an encoding sequence. If the value in the array for a -byte is zero or positive, then the byte is a single byte encoding that -encodes the Unicode scalar value contained in the array. A -1 in this array -indicates a malformed byte. If the value is --2, -3, or -4, then the byte is the beginning of a 2, 3, or 4 byte sequence -respectively. Multi-byte sequences are sent to the convert function pointed -at in the XML_Encoding structure. This function should return -the Unicode scalar value for the sequence or -1 if the sequence is malformed. - -

One pitfall that novice expat users are likely to fall into is that -although expat may accept input in various encodings, the strings that it -passes to the handlers are always encoded in UTF-8. Your application is -responsible for any translation of these strings into other encodings. +

XML_Encoding contains an array of integers that +correspond to the 1st byte of an encoding sequence. If the value in +the array for a byte is zero or positive, then the byte is a single +byte encoding that encodes the Unicode scalar value contained in the +array. A -1 in this array indicates a malformed byte. If the value is +-2, -3, or -4, then the byte is the beginning of a 2, 3, or 4 byte +sequence respectively. Multi-byte sequences are sent to the convert +function pointed at in the XML_Encoding structure. This +function should return the Unicode scalar value for the sequence or -1 +if the sequence is malformed.

+ +

One pitfall that novice Expat users are likely to fall into is that +although Expat may accept input in various encodings, the strings that +it passes to the handlers are always encoded in UTF-8 or UTF-16 +(depending on how Expat was compiled). Your application is responsible +for any translation of these strings into other encodings.

Handling External Entity References

-

Expat does not read or parse external entities directly. Note that any -external DTD is a special case of an external entity. -If you've set no ExternalEntityRefHandler, then external -entity references are silently ignored. Otherwise, it calls your handler with -the information needed to read and parse the external entity. - -

Your handler -isn't actually responsible for parsing the entity, but it is responsible -for creating a subsidiary parser with -XML_ExternalEntityParserCreate that will do the job. This returns -an instance of XML_Parser that has handlers and other data -structures initialized from the parent parser. You may then use -XML_Parse or XML_ParseBuffer calls against this -parser. -Since external entities my refer to other external entities, your handler -should be prepared to be called recursively. +

Expat does not read or parse external entities directly. Note that +any external DTD is a special case of an external entity. If you've +set no ExternalEntityRefHandler, then external entity +references are silently ignored. Otherwise, it calls your handler with +the information needed to read and parse the external entity.

+ +

Your handler isn't actually responsible for parsing the entity, but +it is responsible for creating a subsidiary parser with XML_ExternalEntityParserCreate that will do the job. This +returns an instance of XML_Parser that has handlers and +other data structures initialized from the parent parser. You may then +use XML_Parse or XML_ParseBuffer calls against this +parser. Since external entities my refer to other external entities, +your handler should be prepared to be called recursively.

Parsing DTDs

-

In order to parse parameter entities, before starting the parse, you must -call XML_SetParamEntityParsing with one of the following -arguments: + +

In order to parse parameter entities, before starting the parse, +you must call XML_SetParamEntityParsing with one of the following +arguments:

XML_PARAM_ENTITY_PARSING_NEVER
Don't parse parameter entities or the external subset
@@ -547,41 +701,38 @@ arguments:
Always parse parameter entities and the external subset
-

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


-

Some expat Examples

+

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

-
+

Expat Reference

Parser Creation

- +
+XML_Parser XMLCALL
+XML_ParserCreate(const XML_Char *encoding);
+
Construct a new parser. If encoding is non-null, it specifies a character encoding to use for the document. This overrides the document encoding declaration. There are four built-in encodings:
    -
  • US-ASCII -
  • UTF-8 -
  • UTF-16 -
  • ISO-8859-1 +
  • US-ASCII
  • +
  • UTF-8
  • +
  • UTF-16
  • +
  • ISO-8859-1
Any other value will invoke a call to the UnknownEncodingHandler.
- + XML_Char sep); +
Constructs a new parser that has namespace processing in effect. Namespace expanded element names and attribute names are returned as a concatenation @@ -589,63 +740,95 @@ of the namespace URI, sep, and means that you should pick a character for sep that can't be part of a legal URI.
- + const XML_Char *sep); + +
+typedef struct {
+  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;
+

Construct a new parser using the suite of memory handling functions specified in ms. If ms is NULL, then use the standard set of memory management functions. If sep is non NULL, then namespace processing is enabled in the created parser and the character pointed at by sep is used as the separator between -the namespace URI and the local part of the name

-
-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;
-
+the namespace URI and the local part of the name.

- + const XML_Char *encoding); +
-Construct a new XML_Parser object for parsing an external general -entity. Context is the context argument passed in a call to a -ExternalEntityRefHandler. Other state information such as handlers, user data, -namespace processing is inherited from the parser passed as the 1st -argument. So you shouldn't need to call any of the behavior changing -functions on this parser (unless you want it to act differently than the -parent parser.) +Construct a new XML_Parser object for parsing an external +general entity. Context is the context argument passed in a call to a +ExternalEntityRefHandler. Other state information such as handlers, +user data, namespace processing is inherited from the parser passed as +the 1st argument. So you shouldn't need to call any of the behavior +changing functions on this parser (unless you want it to act +differently than the parent parser).
- +
+void XMLCALL
+XML_ParserFree(XML_Parser p);
+
Free memory used by the parser. Your application is responsible for -freeing any memory associated with UserData. +freeing any memory associated with user data. +
+ +
+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 +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_ExternalEntityParserCreate.

- + int isFinal); + +
+enum XML_Status {
+  XML_STATUS_ERROR = 0,
+  XML_STATUS_OK = 1
+};
+
Parse some more of the document. The string s is a buffer containing part (or perhaps all) of the document. The number of bytes of s @@ -656,35 +839,37 @@ memory that s points at, th isFinal parameter informs the parser that this is the last piece of the document. Frequently, the last piece is empty (i.e. len is zero.) -If a parse error occurred, it returns 0. Otherwise it returns a non-zero -value. +If a parse error occurred, it returns XML_STATUS_ERROR. +Otherwise it returns XML_STATUS_OK value.
- + int isFinal); +
-This is just like XML_Parse, except in this case expat provides the buffer. -By obtaining the buffer from expat with the XML_GetBuffer -function, the application can avoid double copying of the input. +This is just like XML_Parse, +except in this case Expat provides the buffer. By obtaining the +buffer from Expat with the XML_GetBuffer function, the application can avoid double +copying of the input.
- + int len); +
Obtain a buffer of size len to read a piece of the document -into. A NULL value is returned if expat can't allocate enough memory for +into. A NULL value is returned if Expat can't allocate enough memory for this buffer. This has to be called prior to every call to -XML_ParseBuffer. A typical use would look like this: +XML_ParseBuffer. A +typical use would look like this: -
-
+
 for (;;) {
   int bytes_read;
   void *buff = XML_GetBuffer(p, BUFF_SIZE);
@@ -693,7 +878,7 @@ for (;;) {
   }
 
   bytes_read = read(docfd, buff, BUFF_SIZE);
-  if (bytes_read < 0) {
+  if (bytes_read < 0) {
     /* handle error */
   }
 
@@ -703,40 +888,41 @@ for (;;) {
 
   if (bytes_read == 0)
     break;
-}  
+}
 
-

Handler Setting

+

Although handlers are typically set prior to parsing and left alone, an application may choose to set or change the handler for a parsing event while the parse is in progress. For instance, your application may choose to ignore all text not descended from a para element. One way it could do this is to set the character handler when a para start tag -is seen, and unset it for the corresponding end tag. +is seen, and unset it for the corresponding end tag.

A handler may be unset by providing a NULL pointer to the appropriate handler setter. None of the handler setting functions have -a return value. +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 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.

- -
+
+
 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 a start (or empty) tag occupies 2 consecutive places in this vector: the @@ -747,41 +933,44 @@ by a null pointer.

- -
+
+
 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.

- -
+
+
 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 zero terminated. You have to use the length argument +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 @@ -789,173 +978,262 @@ be split across calls to this handler.

- -
+
+
 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 in the processing instruction. The data is the rest of the characters in it after skipping all whitespace after the initial word.

- -
+
+
 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.

- -
+
+
 typedef void
-(*XML_StartCdataSectionHandler)(void *userData);
-
+(XMLCALL *XML_StartCdataSectionHandler)(void *userData); +

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

- -
+
+
 typedef void
-(*XML_EndCdataSectionHandler)(void *userData);
-
+(XMLCALL *XML_EndCdataSectionHandler)(void *userData); +

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

- -
+
+
 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 -otherwise be handled. This includes both data for which no handlers can be -set (like some kinds of DTD declarations) and data which could be reported -but which currently has no handler set. Note that a contiguous piece of -data that is destined to be reported to the default handler may actually -be reported over several calls to the handler. Setting the handler with +otherwise be handled. This includes both data for which no handlers +can be set (like some kinds of DTD declarations) and data which could +be reported but which currently has no handler set. The characters +are passed exactly as they were present in the XML document except +that they will be encoded in UTF-8 or UTF-16. 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 calls to the default handler: for example, a comment +might be split between multiple calls. Setting the handler with this call has the side effect of turning off expansion of references to internally defined general entities. Instead these references are passed to the default handler.

+ +

See also XML_DefaultCurrent.

- -
+
+
 typedef void
-(*XML_DefaultHandler)(void *userData,
-                      const XML_Char *s,
-                      int len);
-
-

This sets a default handler, but doesn't affect expansion of internal -entity references.

+(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 +to the default handler.

+ +

See also XML_DefaultCurrent.

- -
+
+
 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 is in effect. (See XML_SetParamEntityParsing.)

- -

The base parameter is the base to use for relative system identifiers. -It is set by XML_SetBase and may be null. The -public id parameter is the public id given in the entity declaration and -may be null. The system id is the system identifier specified in the entity -declaration and is never null.

- -

There are a couple of ways in which this handler differs from others. -First, this handler returns an integer. A non-zero value should be returned -for successful handling of the external entity reference. Returning a zero -indicates failure, and causes the calling parser to return -an XML_ERROR_EXTERNAL_ENTITY_HANDLING error.

- -

Second, instead of having userData as its first argument, it receives the -parser that encountered the entity reference. This, along with the context -parameter, may be used as arguments to a call to -XML_ExternalEntityParserCreate. -Using the returned parser, the body of the external entity can be recursively -parsed.

+

The context parameter specifies the parsing context in +the format expected by the context argument to XML_ExternalEntityParserCreate. code is +valid only until the handler returns, so if the referenced entity is +to be parsed later, it must be copied. context is NULL +only when the entity is a parameter entity, which is how one can +differentiate between general and parameter entities.

+ +

The base parameter is the base to use for relative +system identifiers. It is set by XML_SetBase and may be NULL. The +publicId parameter is the public id given in the entity +declaration and may be NULL. systemId is the system +identifier specified in the entity declaration and is never NULL.

+ +

There are a couple of ways in which this handler differs from +others. First, this handler returns a status indicator (an +integer). XML_STATUS_OK should be returned for successful +handling of the external entity reference. Returning +XML_STATUS_ERROR indicates failure, and causes the +calling parser to return an +XML_ERROR_EXTERNAL_ENTITY_HANDLING error.

+ +

Second, instead of having the user data as its first argument, it +receives the parser that encountered the entity reference. This, along +with the context parameter, may be used as arguments to a call to +XML_ExternalEntityParserCreate. Using the returned +parser, the body of the external entity can be recursively parsed.

Since this handler may be called recursively, it should not be saving information into global or static variables.

+
+void XMLCALL
+XML_SetExternalEntityRefHandlerArg(XML_Parser p,
+                                   void *arg)
+
+
+

Set the argument passed to the ExternalEntityRefHandler. If +arg is not NULL, it is the new value passed to the +handler set using XML_SetExternalEntityRefHandler; if arg is +NULL, the argument passed to the handler function will be the parser +object itself.

+ +

Note: +The type of arg and the type of the first argument to the +ExternalEntityRefHandler do not match. This function takes a +void * to be passed to the handler, while the handler +accepts an XML_Parser. This is a historical accident, +but will not be corrected before Expat 2.0 (at the earliest) to avoid +causing compiler warnings for code that's known to work with this +API. It is the responsibility of the application code to know the +actual type of the argument passed to the handler and to manage it +properly.

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

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

+
    +
  1. An entity reference is encountered for which no declaration + has been read and this is not an error.
  2. +
  3. An internal entity reference is read, but not expanded, because + XML_SetDefaultHandler + has been called.
  4. +
+

The is_parameter_entity argument will be non-zero for +a parameter entity and zero for a general entity.

Note: skipped +parameter entities in declarations and skipped general entities in +attribute values cannot be reported, because the event would be out of +sync with the reporting of the declarations or attribute values

+
+
- -
+
+
 typedef int
-(*XML_UnknownEncodingHandler)(void *encodingHandlerData,
-                              const XML_Char *name,
-                              XML_Encoding *info);
-
-

Set a handler to deal with encodings other than the -built in set. If the handler knows how -to deal with an encoding with the given name, it should fill in the info -data structure and return 1. Otherwise it should return 0.

+(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);
-    } XML_Encoding;
+typedef struct {
+  int map[256];
+  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_Parse or 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 +at most once per parsed (external) entity. The optional application +data pointer encodingHandlerData will be passed back to +the handler.

The map array contains information for every possible possible leading byte in a byte sequence. If the corresponding value is >= 0, then it's @@ -966,24 +1244,26 @@ bytes in the sequence and the actual con call to the function pointed at by convert. This function may return -1 if the sequence itself is invalid. The convert pointer may be null if there are only single byte codes. The data parameter passed to the convert -function is the data pointer from XML_Encoding. The string s is NOT -null terminated and points at the sequence of bytes to be converted.

+function is the data pointer from XML_Encoding. The +string s is NOT nul-terminated and points at the sequence of +bytes to be converted.

-

The function pointed at by release is called by the parser when it is -finished with the encoding. It may be null.

+

The function pointed at by release is called by the +parser when it is finished with the encoding. It may be NULL.

- -
+
+
 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 @@ -991,64 +1271,69 @@ in that start tag.

- -
+
+
 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. -

+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.

- -

Sets both namespace declaration handlers with a single call

+ +

Sets both namespace declaration handlers with a single call.

- -
+
+
 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 distinguish -is that the version parameter will be NULL for text -declarations. The encoding parameter may be NULL for -an XML declaration. The standalone argument will contain --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.

+text declarations discovered in external entities. The way to +distinguish is that the version parameter will be NULL +for text declarations. The encoding parameter may be NULL +for an XML declaration. The standalone argument will +contain -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_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 and pubid may be NULL. The has_internal_subset @@ -1056,39 +1341,42 @@ will be non-zero if the DOCTYPE declarat

- -
+
+
 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.

- -
+
+
 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 {
   XML_CTYPE_EMPTY = 1,
   XML_CTYPE_ANY,
@@ -1114,341 +1402,376 @@ struct XML_cp {
   unsigned int			numchildren;
   XML_Content *			children;
 };
-
-

Sets a handler for element declarations in a DTD. The handler gets called -with the name of the element in the declaration and a pointer to a structure -that contains the element model. It is the application's responsibility to -free this data structure.

+ +

Sets a handler for element declarations in a DTD. The handler gets +called with the name of the element in the declaration and a pointer +to a structure that contains the element model. It is the +application's responsibility to free this data structure using +XML_FreeContentModel.

The model argument is the root of a tree of XML_Content nodes. If type equals 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 is XML_CTYPE_MIXED, then quant -will be XML_CQUANT_NONE or XML_CQUANT_REP and -numchildren will contain the number of elements that are allowed -to be mixed in and children points to an array of -XML_Content structures that will all have type XML_CTYPE_NAME -with no quantification. -Only the root node can be type XML_CTYPE_EMPTY, XML_CTYPE_ANY, or XML_CTYPE_MIXED.

- -

For type XML_CTYPE_NAME, the name field points -to the name and the numchildren and children fields -will be zero and NULL. The quant field will indicate any -quantifiers placed on the name.

+quant will be XML_CQUANT_NONE, and the other +fields will be zero or NULL. If type is +XML_CTYPE_MIXED, then quant will be +XML_CQUANT_NONE or XML_CQUANT_REP and +numchildren will contain the number of elements that are +allowed to be mixed in and children points to an array of +XML_Content structures that will all have type +XML_CTYPE_NAME with no quantification. Only the root node can be type +XML_CTYPE_EMPTY, XML_CTYPE_ANY, or +XML_CTYPE_MIXED.

+ +

For type XML_CTYPE_NAME, the name field +points to the name and the numchildren and +children fields will be zero and NULL. The +quant field will indicate any quantifiers placed on the +name.

Types XML_CTYPE_CHOICE and XML_CTYPE_SEQ -indicate a choice or sequence respectively. The numchildren -field indicates how many nodes in the choice or sequence and -children points to the nodes.

+indicate a choice or sequence respectively. The +numchildren field indicates how many nodes in the choice +or sequence and children points to the nodes.

[... 773 lines stripped ...]