Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 1 | \section{\module{xml.parsers.expat} --- |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 2 | Fast XML parsing using Expat} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 3 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 4 | % Markup notes: |
| 5 | % |
| 6 | % Many of the attributes of the XMLParser objects are callbacks. |
| 7 | % Since signature information must be presented, these are described |
| 8 | % using the methoddesc environment. Since they are attributes which |
| 9 | % are set by client code, in-text references to these attributes |
| 10 | % should be marked using the \member macro and should not include the |
| 11 | % parentheses used when marking functions and methods. |
| 12 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 13 | \declaremodule{standard}{xml.parsers.expat} |
| 14 | \modulesynopsis{An interface to the Expat non-validating XML parser.} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 15 | \moduleauthor{Paul Prescod}{paul@prescod.net} |
| 16 | \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} |
| 17 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 18 | \versionadded{2.0} |
| 19 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 20 | The \module{xml.parsers.expat} module is a Python interface to the |
| 21 | Expat\index{Expat} non-validating XML parser. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 22 | The module provides a single extension type, \class{xmlparser}, that |
| 23 | represents the current state of an XML parser. After an |
| 24 | \class{xmlparser} object has been created, various attributes of the object |
| 25 | can be set to handler functions. When an XML document is then fed to |
| 26 | the parser, the handler functions are called for the character data |
| 27 | and markup in the XML document. |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 28 | |
| 29 | This module uses the \module{pyexpat}\refbimodindex{pyexpat} module to |
| 30 | provide access to the Expat parser. Direct use of the |
| 31 | \module{pyexpat} module is deprecated. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 32 | |
| 33 | This module provides one exception and one type object: |
| 34 | |
Fred Drake | 1d8ad2b | 2001-02-14 18:54:32 +0000 | [diff] [blame^] | 35 | \begin{excdesc}{ExpatError} |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 36 | The exception raised when Expat reports an error. |
| 37 | \end{excdesc} |
| 38 | |
Fred Drake | 1d8ad2b | 2001-02-14 18:54:32 +0000 | [diff] [blame^] | 39 | \begin{excdesc}{error} |
| 40 | Alias for \exception{ExpatError}. |
| 41 | \end{excdesc} |
| 42 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 43 | \begin{datadesc}{XMLParserType} |
| 44 | The type of the return values from the \function{ParserCreate()} |
| 45 | function. |
| 46 | \end{datadesc} |
| 47 | |
| 48 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 49 | The \module{xml.parsers.expat} module contains two functions: |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 50 | |
| 51 | \begin{funcdesc}{ErrorString}{errno} |
| 52 | Returns an explanatory string for a given error number \var{errno}. |
| 53 | \end{funcdesc} |
| 54 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 55 | \begin{funcdesc}{ParserCreate}{\optional{encoding\optional{, |
| 56 | namespace_separator}}} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 57 | Creates and returns a new \class{xmlparser} object. |
| 58 | \var{encoding}, if specified, must be a string naming the encoding |
| 59 | used by the XML data. Expat doesn't support as many encodings as |
| 60 | Python does, and its repertoire of encodings can't be extended; it |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 61 | supports UTF-8, UTF-16, ISO-8859-1 (Latin1), and ASCII. If |
| 62 | \var{encoding} is given it will override the implicit or explicit |
| 63 | encoding of the document. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 64 | |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 65 | Expat can optionally do XML namespace processing for you, enabled by |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 66 | providing a value for \var{namespace_separator}. The value must be a |
| 67 | one-character string; a \exception{ValueError} will be raised if the |
| 68 | string has an illegal length (\code{None} is considered the same as |
| 69 | omission). When namespace processing is enabled, element type names |
| 70 | and attribute names that belong to a namespace will be expanded. The |
| 71 | element name passed to the element handlers |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 72 | \member{StartElementHandler} and \member{EndElementHandler} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 73 | will be the concatenation of the namespace URI, the namespace |
| 74 | separator character, and the local part of the name. If the namespace |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 75 | separator is a zero byte (\code{chr(0)}) then the namespace URI and |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 76 | the local part will be concatenated without any separator. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 77 | |
Fred Drake | 2fef3ab | 2000-11-28 06:38:22 +0000 | [diff] [blame] | 78 | For example, if \var{namespace_separator} is set to a space character |
| 79 | (\character{ }) and the following document is parsed: |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 80 | |
| 81 | \begin{verbatim} |
| 82 | <?xml version="1.0"?> |
| 83 | <root xmlns = "http://default-namespace.org/" |
| 84 | xmlns:py = "http://www.python.org/ns/"> |
| 85 | <py:elem1 /> |
| 86 | <elem2 xmlns="" /> |
| 87 | </root> |
| 88 | \end{verbatim} |
| 89 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 90 | \member{StartElementHandler} will receive the following strings |
Fred Drake | d79c33a | 2000-09-25 14:14:30 +0000 | [diff] [blame] | 91 | for each element: |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 92 | |
| 93 | \begin{verbatim} |
| 94 | http://default-namespace.org/ root |
| 95 | http://www.python.org/ns/ elem1 |
| 96 | elem2 |
| 97 | \end{verbatim} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 98 | \end{funcdesc} |
| 99 | |
Fred Drake | f08cbb1 | 2000-12-23 22:19:05 +0000 | [diff] [blame] | 100 | |
| 101 | \subsection{XMLParser Objects \label{xmlparser-objects}} |
| 102 | |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 103 | \class{xmlparser} objects have the following methods: |
| 104 | |
Fred Drake | 2fef3ab | 2000-11-28 06:38:22 +0000 | [diff] [blame] | 105 | \begin{methoddesc}[xmlparser]{Parse}{data\optional{, isfinal}} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 106 | Parses the contents of the string \var{data}, calling the appropriate |
| 107 | handler functions to process the parsed data. \var{isfinal} must be |
Fred Drake | f08cbb1 | 2000-12-23 22:19:05 +0000 | [diff] [blame] | 108 | true on the final call to this method. \var{data} can be the empty |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 109 | string at any time. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 110 | \end{methoddesc} |
| 111 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 112 | \begin{methoddesc}[xmlparser]{ParseFile}{file} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 113 | Parse XML data reading from the object \var{file}. \var{file} only |
| 114 | needs to provide the \method{read(\var{nbytes})} method, returning the |
| 115 | empty string when there's no more data. |
| 116 | \end{methoddesc} |
| 117 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 118 | \begin{methoddesc}[xmlparser]{SetBase}{base} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 119 | Sets the base to be used for resolving relative URIs in system |
| 120 | identifiers in declarations. Resolving relative identifiers is left |
| 121 | to the application: this value will be passed through as the |
| 122 | \var{base} argument to the \function{ExternalEntityRefHandler}, |
| 123 | \function{NotationDeclHandler}, and |
| 124 | \function{UnparsedEntityDeclHandler} functions. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 125 | \end{methoddesc} |
| 126 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 127 | \begin{methoddesc}[xmlparser]{GetBase}{} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 128 | Returns a string containing the base set by a previous call to |
| 129 | \method{SetBase()}, or \code{None} if |
| 130 | \method{SetBase()} hasn't been called. |
| 131 | \end{methoddesc} |
| 132 | |
Fred Drake | 1d8ad2b | 2001-02-14 18:54:32 +0000 | [diff] [blame^] | 133 | \begin{methoddesc}[xmlparser]{GetInputContext}{} |
| 134 | Returns the input data that generated the current event as a string. |
| 135 | The data is in the encoding of the entity which contains the text. |
| 136 | When called while an event handler is not active, the return value is |
| 137 | \code{None}. |
| 138 | \versionadded{2.1} |
| 139 | \end{methoddesc} |
| 140 | |
Fred Drake | f08cbb1 | 2000-12-23 22:19:05 +0000 | [diff] [blame] | 141 | \begin{methoddesc}[xmlparser]{ExternalEntityParserCreate}{context\optional{, |
| 142 | encoding}} |
| 143 | Create a ``child'' parser which can be used to parse an external |
| 144 | parsed entity referred to by content parsed by the parent parser. The |
Fred Drake | b162d18 | 2001-01-04 05:48:08 +0000 | [diff] [blame] | 145 | \var{context} parameter should be the string passed to the |
Fred Drake | f08cbb1 | 2000-12-23 22:19:05 +0000 | [diff] [blame] | 146 | \method{ExternalEntityRefHandler()} handler function, described below. |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 147 | The child parser is created with the \member{ordered_attributes}, |
| 148 | \member{returns_unicode} and \member{specified_attributes} set to the |
| 149 | values of this parser. |
Fred Drake | f08cbb1 | 2000-12-23 22:19:05 +0000 | [diff] [blame] | 150 | \end{methoddesc} |
| 151 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 152 | |
Fred Drake | d79c33a | 2000-09-25 14:14:30 +0000 | [diff] [blame] | 153 | \class{xmlparser} objects have the following attributes: |
Andrew M. Kuchling | 0690c86 | 2000-08-17 23:15:21 +0000 | [diff] [blame] | 154 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 155 | \begin{memberdesc}[xmlparser]{ordered_attributes} |
| 156 | Setting this attribute to a non-zero integer causes the attributes to |
| 157 | be reported as a list rather than a dictionary. The attributes are |
| 158 | presented in the order found in the document text. For each |
| 159 | attribute, two list entries are presented: the attribute name and the |
| 160 | attribute value. (Older versions of this module also used this |
| 161 | format.) By default, this attribute is false; it may be changed at |
| 162 | any time. |
| 163 | \versionadded{2.1} |
| 164 | \end{memberdesc} |
| 165 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 166 | \begin{memberdesc}[xmlparser]{returns_unicode} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 167 | If this attribute is set to a non-zero integer, the handler functions |
| 168 | will be passed Unicode strings. If \member{returns_unicode} is 0, |
| 169 | 8-bit strings containing UTF-8 encoded data will be passed to the |
| 170 | handlers. |
Fred Drake | b62966c | 2000-12-07 00:00:21 +0000 | [diff] [blame] | 171 | \versionchanged[Can be changed at any time to affect the result |
| 172 | type.]{1.6} |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 173 | \end{memberdesc} |
Andrew M. Kuchling | 0690c86 | 2000-08-17 23:15:21 +0000 | [diff] [blame] | 174 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 175 | \begin{memberdesc}[xmlparser]{specified_attributes} |
| 176 | If set to a non-zero integer, the parser will report only those |
| 177 | attributes which were specified in the document instance and not those |
| 178 | which were derived from attribute declarations. Applications which |
| 179 | set this need to be especially careful to use what additional |
| 180 | information is available from the declarations as needed to comply |
| 181 | with the standards for the behavior of XML processors. By default, |
| 182 | this attribute is false; it may be changed at any time. |
| 183 | \versionadded{2.1} |
| 184 | \end{memberdesc} |
| 185 | |
Andrew M. Kuchling | 0690c86 | 2000-08-17 23:15:21 +0000 | [diff] [blame] | 186 | The following attributes contain values relating to the most recent |
| 187 | error encountered by an \class{xmlparser} object, and will only have |
| 188 | correct values once a call to \method{Parse()} or \method{ParseFile()} |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 189 | has raised a \exception{xml.parsers.expat.error} exception. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 190 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 191 | \begin{memberdesc}[xmlparser]{ErrorByteIndex} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 192 | Byte index at which an error occurred. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 193 | \end{memberdesc} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 194 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 195 | \begin{memberdesc}[xmlparser]{ErrorCode} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 196 | Numeric code specifying the problem. This value can be passed to the |
| 197 | \function{ErrorString()} function, or compared to one of the constants |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 198 | defined in the \module{errors} object. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 199 | \end{memberdesc} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 200 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 201 | \begin{memberdesc}[xmlparser]{ErrorColumnNumber} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 202 | Column number at which an error occurred. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 203 | \end{memberdesc} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 204 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 205 | \begin{memberdesc}[xmlparser]{ErrorLineNumber} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 206 | Line number at which an error occurred. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 207 | \end{memberdesc} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 208 | |
| 209 | Here is the list of handlers that can be set. To set a handler on an |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 210 | \class{xmlparser} object \var{o}, use |
| 211 | \code{\var{o}.\var{handlername} = \var{func}}. \var{handlername} must |
| 212 | be taken from the following list, and \var{func} must be a callable |
| 213 | object accepting the correct number of arguments. The arguments are |
| 214 | all strings, unless otherwise stated. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 215 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 216 | \begin{methoddesc}[xmlparser]{XmlDeclHandler}{version, encoding, standalone} |
| 217 | Called when the XML declaration is parsed. The XML declaration is the |
| 218 | (optional) declaration of the applicable version of the XML |
| 219 | recommendation, the encoding of the document text, and an optional |
| 220 | ``standalone'' declaration. \var{version} and \var{encoding} will be |
| 221 | strings of the type dictated by the \member{returns_unicode} |
| 222 | attribute, and \var{standalone} will be \code{1} if the document is |
| 223 | declared standalone, \code{0} if it is declared not to be standalone, |
| 224 | or \code{-1} if the standalone clause was omitted. |
| 225 | This is only available with Expat version 1.95.0 or newer. |
| 226 | \versionadded{2.1} |
| 227 | \end{methoddesc} |
| 228 | |
| 229 | \begin{methoddesc}[xmlparser]{StartDoctypeDeclHandler}{doctypeName, |
| 230 | systemId, publicId, |
| 231 | has_internal_subset} |
| 232 | Called when Expat begins parsing the document type declaration |
| 233 | (\code{<!DOCTYPE \ldots}). The \var{doctypeName} is provided exactly |
| 234 | as presented. The \var{systemId} and \var{publicId} parameters give |
| 235 | the system and public identifiers if specified, or \code{None} if |
| 236 | omitted. \var{has_internal_subset} will be true if the document |
| 237 | contains and internal document declaration subset. |
| 238 | This requires Expat version 1.2 or newer. |
| 239 | \end{methoddesc} |
| 240 | |
| 241 | \begin{methoddesc}[xmlparser]{EndDoctypeDeclHandler}{} |
| 242 | Called when Expat is done parsing the document type delaration. |
| 243 | This requires Expat version 1.2 or newer. |
| 244 | \end{methoddesc} |
| 245 | |
| 246 | \begin{methoddesc}[xmlparser]{ElementDeclHandler}{name, model} |
| 247 | Called once for each element type declaration. \var{name} is the name |
| 248 | of the element type, and \var{model} is a representation of the |
| 249 | content model. |
| 250 | \end{methoddesc} |
| 251 | |
| 252 | \begin{methoddesc}[xmlparser]{AttlistDeclHandler}{elname, attname, |
| 253 | type, default, required} |
| 254 | Called for each declared attribute for an element type. If an |
| 255 | attribute list declaration declares three attributes, this handler is |
| 256 | called three times, once for each attribute. \var{elname} is the name |
| 257 | of the element to which the declaration applies and \var{attname} is |
| 258 | the name of the attribute declared. The attribute type is a string |
| 259 | passed as \var{type}; the possible values are \code{'CDATA'}, |
| 260 | \code{'ID'}, \code{'IDREF'}, ... |
| 261 | \var{default} gives the default value for the attribute used when the |
| 262 | attribute is not specified by the document instance, or \code{None} if |
| 263 | there is no default value (\code{\#IMPLIED} values). If the attribute |
| 264 | is required to be given in the document instance, \var{required} will |
| 265 | be true. |
| 266 | This requires Expat version 1.95.0 or newer. |
| 267 | \end{methoddesc} |
| 268 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 269 | \begin{methoddesc}[xmlparser]{StartElementHandler}{name, attributes} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 270 | Called for the start of every element. \var{name} is a string |
| 271 | containing the element name, and \var{attributes} is a dictionary |
| 272 | mapping attribute names to their values. |
| 273 | \end{methoddesc} |
| 274 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 275 | \begin{methoddesc}[xmlparser]{EndElementHandler}{name} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 276 | Called for the end of every element. |
| 277 | \end{methoddesc} |
| 278 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 279 | \begin{methoddesc}[xmlparser]{ProcessingInstructionHandler}{target, data} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 280 | Called for every processing instruction. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 281 | \end{methoddesc} |
| 282 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 283 | \begin{methoddesc}[xmlparser]{CharacterDataHandler}{data} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 284 | Called for character data. This will be called for normal character |
| 285 | data, CDATA marked content, and ignorable whitespace. Applications |
| 286 | which must distinguish these cases can use the |
| 287 | \member{StartCdataSectionHandler}, \member{EndCdataSectionHandler}, |
| 288 | and \member{ElementDeclHandler} callbacks to collect the required |
| 289 | information. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 290 | \end{methoddesc} |
| 291 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 292 | \begin{methoddesc}[xmlparser]{UnparsedEntityDeclHandler}{entityName, base, |
| 293 | systemId, publicId, |
| 294 | notationName} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 295 | Called for unparsed (NDATA) entity declarations. This is only present |
| 296 | for version 1.2 of the Expat library; for more recent versions, use |
| 297 | \member{EntityDeclHandler} instead. (The underlying function in the |
| 298 | Expat library has been declared obsolete.) |
| 299 | \end{methoddesc} |
| 300 | |
| 301 | \begin{methoddesc}[xmlparser]{EntityDeclHandler}{entityName, |
| 302 | is_parameter_entity, value, |
| 303 | base, systemId, |
| 304 | publicId, |
| 305 | notationName} |
| 306 | Called for all entity declarations. For parameter and internal |
| 307 | entities, \var{value} will be a string giving the declared contents |
| 308 | of the entity; this will be \code{None} for external entities. The |
| 309 | \var{notationName} parameter will be \code{None} for parsed entities, |
| 310 | and the name of the notation for unparsed entities. |
| 311 | \var{is_parameter_entity} will be true if the entity is a paremeter |
| 312 | entity or false for general entities (most applications only need to |
| 313 | be concerned with general entities). |
| 314 | This is only available starting with version 1.95.0 of the Expat |
| 315 | library. |
| 316 | \versionadded{2.1} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 317 | \end{methoddesc} |
| 318 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 319 | \begin{methoddesc}[xmlparser]{NotationDeclHandler}{notationName, base, |
| 320 | systemId, publicId} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 321 | Called for notation declarations. \var{notationName}, \var{base}, and |
| 322 | \var{systemId}, and \var{publicId} are strings if given. If the |
| 323 | public identifier is omitted, \var{publicId} will be \code{None}. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 324 | \end{methoddesc} |
| 325 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 326 | \begin{methoddesc}[xmlparser]{StartNamespaceDeclHandler}{prefix, uri} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 327 | Called when an element contains a namespace declaration. Namespace |
| 328 | declarations are processed before the \member{StartElementHandler} is |
| 329 | called for the element on which declarations are placed. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 330 | \end{methoddesc} |
| 331 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 332 | \begin{methoddesc}[xmlparser]{EndNamespaceDeclHandler}{prefix} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 333 | Called when the closing tag is reached for an element |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 334 | that contained a namespace declaration. This is called once for each |
| 335 | namespace declaration on the element in the reverse of the order for |
| 336 | which the \member{StartNamespaceDeclHandler} was called to indicate |
| 337 | the start of each namespace declaration's scope. Calls to this |
| 338 | handler are made after the corresponding \member{EndElementHandler} |
| 339 | for the end of the element. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 340 | \end{methoddesc} |
| 341 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 342 | \begin{methoddesc}[xmlparser]{CommentHandler}{data} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 343 | Called for comments. \var{data} is the text of the comment, excluding |
| 344 | the leading `\code{<!--}' and trailing `\code{-->}'. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 345 | \end{methoddesc} |
| 346 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 347 | \begin{methoddesc}[xmlparser]{StartCdataSectionHandler}{} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 348 | Called at the start of a CDATA section. This and |
| 349 | \member{StartCdataSectionHandler} are needed to be able to identify |
| 350 | the syntactical start and end for CDATA sections. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 351 | \end{methoddesc} |
| 352 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 353 | \begin{methoddesc}[xmlparser]{EndCdataSectionHandler}{} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 354 | Called at the end of a CDATA section. |
| 355 | \end{methoddesc} |
| 356 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 357 | \begin{methoddesc}[xmlparser]{DefaultHandler}{data} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 358 | Called for any characters in the XML document for |
| 359 | which no applicable handler has been specified. This means |
| 360 | characters that are part of a construct which could be reported, but |
| 361 | for which no handler has been supplied. |
| 362 | \end{methoddesc} |
| 363 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 364 | \begin{methoddesc}[xmlparser]{DefaultHandlerExpand}{data} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 365 | This is the same as the \function{DefaultHandler}, |
| 366 | but doesn't inhibit expansion of internal entities. |
| 367 | The entity reference will not be passed to the default handler. |
| 368 | \end{methoddesc} |
| 369 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 370 | \begin{methoddesc}[xmlparser]{NotStandaloneHandler}{} Called if the |
| 371 | XML document hasn't been declared as being a standalone document. |
| 372 | This happens when there is an external subset or a reference to a |
| 373 | parameter entity, but the XML declaration does not set standalone to |
| 374 | \code{yes} in an XML declaration. If this handler returns \code{0}, |
| 375 | then the parser will throw an \constant{XML_ERROR_NOT_STANDALONE} |
| 376 | error. If this handler is not set, no exception is raised by the |
| 377 | parser for this condition. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 378 | \end{methoddesc} |
| 379 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 380 | \begin{methoddesc}[xmlparser]{ExternalEntityRefHandler}{context, base, |
| 381 | systemId, publicId} |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 382 | Called for references to external entities. \var{base} is the current |
| 383 | base, as set by a previous call to \method{SetBase()}. The public and |
| 384 | system identifiers, \var{systemId} and \var{publicId}, are strings if |
| 385 | given; if the public identifier is not given, \var{publicId} will be |
| 386 | \code{None}. |
| 387 | |
| 388 | For external entities to be parsed, this handler must be implemented. |
| 389 | It is responsible for creating the sub-parser using |
| 390 | \code{ExternalEntityRefHandler(\var{context})}, initializing it with |
| 391 | the appropriate callbacks, and parsing the entity. If this handler |
| 392 | returns \code{0}, the parser will throw an |
| 393 | \constant{XML_ERROR_EXTERNAL_ENTITY_HANDLING} error. |
| 394 | |
| 395 | If this handler is not provided, external entities are reported by the |
| 396 | \member{DefaultHandler} callback, if provided. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 397 | \end{methoddesc} |
| 398 | |
| 399 | |
Fred Drake | 1d8ad2b | 2001-02-14 18:54:32 +0000 | [diff] [blame^] | 400 | \subsection{ExpatError Exceptions \label{expaterror-objects}} |
| 401 | \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org} |
| 402 | |
| 403 | \exception{ExpatError} exceptions have a number of interesting |
| 404 | attributes: |
| 405 | |
| 406 | \begin{memberdesc}[ExpatError]{code} |
| 407 | Expat's internal error number for the specific error. This will |
| 408 | match one of the constants defined in the \code{errors} object from |
| 409 | this module. |
| 410 | \versionadded{2.1} |
| 411 | \end{memberdesc} |
| 412 | |
| 413 | \begin{memberdesc}[ExpatError]{lineno} |
| 414 | Line number on which the error was detected. The first line is |
| 415 | numbered \code{1}. |
| 416 | \versionadded{2.1} |
| 417 | \end{memberdesc} |
| 418 | |
| 419 | \begin{memberdesc}[ExpatError]{offset} |
| 420 | Character offset into the line where the error occurred. The first |
| 421 | column is numbered \code{0}. |
| 422 | \versionadded{2.1} |
| 423 | \end{memberdesc} |
| 424 | |
| 425 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 426 | \subsection{Example \label{expat-example}} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 427 | |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 428 | The following program defines three handlers that just print out their |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 429 | arguments. |
| 430 | |
| 431 | \begin{verbatim} |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 432 | import xml.parsers.expat |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 433 | |
| 434 | # 3 handler functions |
| 435 | def start_element(name, attrs): |
| 436 | print 'Start element:', name, attrs |
| 437 | def end_element(name): |
| 438 | print 'End element:', name |
| 439 | def char_data(data): |
| 440 | print 'Character data:', repr(data) |
| 441 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 442 | p = xml.parsers.expat.ParserCreate() |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 443 | |
| 444 | p.StartElementHandler = start_element |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 445 | p.EndElementHandler = end_element |
| 446 | p.CharacterDataHandler = char_data |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 447 | |
| 448 | p.Parse("""<?xml version="1.0"?> |
| 449 | <parent id="top"><child1 name="paul">Text goes here</child1> |
| 450 | <child2 name="fred">More text</child2> |
| 451 | </parent>""") |
| 452 | \end{verbatim} |
| 453 | |
| 454 | The output from this program is: |
| 455 | |
| 456 | \begin{verbatim} |
| 457 | Start element: parent {'id': 'top'} |
| 458 | Start element: child1 {'name': 'paul'} |
| 459 | Character data: 'Text goes here' |
| 460 | End element: child1 |
Ka-Ping Yee | fa004ad | 2001-01-24 17:19:08 +0000 | [diff] [blame] | 461 | Character data: '\n' |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 462 | Start element: child2 {'name': 'fred'} |
| 463 | Character data: 'More text' |
| 464 | End element: child2 |
Ka-Ping Yee | fa004ad | 2001-01-24 17:19:08 +0000 | [diff] [blame] | 465 | Character data: '\n' |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 466 | End element: parent |
| 467 | \end{verbatim} |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 468 | |
| 469 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 470 | \subsection{Content Model Descriptions \label{expat-content-models}} |
| 471 | \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org} |
| 472 | |
| 473 | Content modules are described using nested tuples. Each tuple |
| 474 | contains four values: the type, the quantifier, the name, and a tuple |
| 475 | of children. Children are simply additional content module |
| 476 | descriptions. |
| 477 | |
| 478 | The values of the first two fields are constants defined in the |
| 479 | \code{model} object of the \module{xml.parsers.expat} module. These |
| 480 | constants can be collected in two groups: the model type group and the |
| 481 | quantifier group. |
| 482 | |
| 483 | The constants in the model type group are: |
| 484 | |
| 485 | \begin{datadescni}{XML_CTYPE_ANY} |
| 486 | The element named by the model name was declared to have a content |
| 487 | model of \code{ANY}. |
| 488 | \end{datadescni} |
| 489 | |
| 490 | \begin{datadescni}{XML_CTYPE_CHOICE} |
| 491 | The named element allows a choice from a number of options; this is |
| 492 | used for content models such as \code{(A | B | C)}. |
| 493 | \end{datadescni} |
| 494 | |
| 495 | \begin{datadescni}{XML_CTYPE_EMPTY} |
| 496 | Elements which are declared to be \code{EMPTY} have this model type. |
| 497 | \end{datadescni} |
| 498 | |
| 499 | \begin{datadescni}{XML_CTYPE_MIXED} |
| 500 | \end{datadescni} |
| 501 | |
| 502 | \begin{datadescni}{XML_CTYPE_NAME} |
| 503 | \end{datadescni} |
| 504 | |
| 505 | \begin{datadescni}{XML_CTYPE_SEQ} |
| 506 | Models which represent a series of models which follow one after the |
| 507 | other are indicated with this model type. This is used for models |
| 508 | such as \code{(A, B, C)}. |
| 509 | \end{datadescni} |
| 510 | |
| 511 | |
| 512 | The constants in the quantifier group are: |
| 513 | |
| 514 | \begin{datadescni}{XML_CQUANT_NONE} |
| 515 | \end{datadescni} |
| 516 | |
| 517 | \begin{datadescni}{XML_CQUANT_OPT} |
| 518 | The model is option: it can appear once or not at all, as for |
| 519 | \code{A?}. |
| 520 | \end{datadescni} |
| 521 | |
| 522 | \begin{datadescni}{XML_CQUANT_PLUS} |
| 523 | The model must occur one or more times (\code{A+}). |
| 524 | \end{datadescni} |
| 525 | |
| 526 | \begin{datadescni}{XML_CQUANT_REP} |
| 527 | The model must occur zero or more times, as for \code{A*}. |
| 528 | \end{datadescni} |
| 529 | |
| 530 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 531 | \subsection{Expat error constants \label{expat-errors}} |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 532 | \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} |
| 533 | |
Fred Drake | 1d8ad2b | 2001-02-14 18:54:32 +0000 | [diff] [blame^] | 534 | The following constants are provided in the \code{errors} object of |
| 535 | the \refmodule{xml.parsers.expat} module. These constants are useful |
| 536 | in interpreting some of the attributes of the \exception{ExpatError} |
| 537 | exception objects raised when an error has occurred. |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 538 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 539 | The \code{errors} object has the following attributes: |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 540 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 541 | \begin{datadescni}{XML_ERROR_ASYNC_ENTITY} |
| 542 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 543 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 544 | \begin{datadescni}{XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF} |
| 545 | An entity reference in an attribute value referred to an external |
| 546 | entity instead of an internal entity. |
| 547 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 548 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 549 | \begin{datadescni}{XML_ERROR_BAD_CHAR_REF} |
| 550 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 551 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 552 | \begin{datadescni}{XML_ERROR_BINARY_ENTITY_REF} |
| 553 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 554 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 555 | \begin{datadescni}{XML_ERROR_DUPLICATE_ATTRIBUTE} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 556 | An attribute was used more than once in a start tag. |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 557 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 558 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 559 | \begin{datadescni}{XML_ERROR_INCORRECT_ENCODING} |
| 560 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 561 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 562 | \begin{datadescni}{XML_ERROR_INVALID_TOKEN} |
| 563 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 564 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 565 | \begin{datadescni}{XML_ERROR_JUNK_AFTER_DOC_ELEMENT} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 566 | Something other than whitespace occurred after the document element. |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 567 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 568 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 569 | \begin{datadescni}{XML_ERROR_MISPLACED_XML_PI} |
| 570 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 571 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 572 | \begin{datadescni}{XML_ERROR_NO_ELEMENTS} |
| 573 | The document contains no elements. |
| 574 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 575 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 576 | \begin{datadescni}{XML_ERROR_NO_MEMORY} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 577 | Expat was not able to allocate memory internally. |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 578 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 579 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 580 | \begin{datadescni}{XML_ERROR_PARAM_ENTITY_REF} |
| 581 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 582 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 583 | \begin{datadescni}{XML_ERROR_PARTIAL_CHAR} |
| 584 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 585 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 586 | \begin{datadescni}{XML_ERROR_RECURSIVE_ENTITY_REF} |
| 587 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 588 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 589 | \begin{datadescni}{XML_ERROR_SYNTAX} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 590 | Some unspecified syntax error was encountered. |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 591 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 592 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 593 | \begin{datadescni}{XML_ERROR_TAG_MISMATCH} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 594 | An end tag did not match the innermost open start tag. |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 595 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 596 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 597 | \begin{datadescni}{XML_ERROR_UNCLOSED_TOKEN} |
| 598 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 599 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 600 | \begin{datadescni}{XML_ERROR_UNDEFINED_ENTITY} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 601 | A reference was made to a entity which was not defined. |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 602 | \end{datadescni} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 603 | |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 604 | \begin{datadescni}{XML_ERROR_UNKNOWN_ENCODING} |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 605 | The document encoding is not supported by Expat. |
Fred Drake | 5ed1dac | 2001-02-08 15:40:33 +0000 | [diff] [blame] | 606 | \end{datadescni} |