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 | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{xml.parsers.expat} |
| 5 | \modulesynopsis{An interface to the Expat non-validating XML parser.} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 6 | \moduleauthor{Paul Prescod}{paul@prescod.net} |
| 7 | \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} |
| 8 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 9 | \versionadded{2.0} |
| 10 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 11 | The \module{xml.parsers.expat} module is a Python interface to the |
| 12 | Expat\index{Expat} non-validating XML parser. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 13 | The module provides a single extension type, \class{xmlparser}, that |
| 14 | represents the current state of an XML parser. After an |
| 15 | \class{xmlparser} object has been created, various attributes of the object |
| 16 | can be set to handler functions. When an XML document is then fed to |
| 17 | the parser, the handler functions are called for the character data |
| 18 | and markup in the XML document. |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 19 | |
| 20 | This module uses the \module{pyexpat}\refbimodindex{pyexpat} module to |
| 21 | provide access to the Expat parser. Direct use of the |
| 22 | \module{pyexpat} module is deprecated. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 23 | |
| 24 | This module provides one exception and one type object: |
| 25 | |
| 26 | \begin{excdesc}{error} |
| 27 | The exception raised when Expat reports an error. |
| 28 | \end{excdesc} |
| 29 | |
| 30 | \begin{datadesc}{XMLParserType} |
| 31 | The type of the return values from the \function{ParserCreate()} |
| 32 | function. |
| 33 | \end{datadesc} |
| 34 | |
| 35 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 36 | The \module{xml.parsers.expat} module contains two functions: |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 37 | |
| 38 | \begin{funcdesc}{ErrorString}{errno} |
| 39 | Returns an explanatory string for a given error number \var{errno}. |
| 40 | \end{funcdesc} |
| 41 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 42 | \begin{funcdesc}{ParserCreate}{\optional{encoding\optional{, |
| 43 | namespace_separator}}} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 44 | Creates and returns a new \class{xmlparser} object. |
| 45 | \var{encoding}, if specified, must be a string naming the encoding |
| 46 | used by the XML data. Expat doesn't support as many encodings as |
| 47 | Python does, and its repertoire of encodings can't be extended; it |
| 48 | supports UTF-8, UTF-16, ISO-8859-1 (Latin1), and ASCII. |
| 49 | |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 50 | Expat can optionally do XML namespace processing for you, enabled by |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 51 | providing a value for \var{namespace_separator}. The value must be a |
| 52 | one-character string; a \exception{ValueError} will be raised if the |
| 53 | string has an illegal length (\code{None} is considered the same as |
| 54 | omission). When namespace processing is enabled, element type names |
| 55 | and attribute names that belong to a namespace will be expanded. The |
| 56 | element name passed to the element handlers |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 57 | \function{StartElementHandler()} and \function{EndElementHandler()} |
| 58 | will be the concatenation of the namespace URI, the namespace |
| 59 | separator character, and the local part of the name. If the namespace |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 60 | separator is a zero byte (\code{chr(0)}) then the namespace URI and |
| 61 | the local part will be concatenated without any separator. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 62 | |
Fred Drake | 2fef3ab | 2000-11-28 06:38:22 +0000 | [diff] [blame] | 63 | For example, if \var{namespace_separator} is set to a space character |
| 64 | (\character{ }) and the following document is parsed: |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 65 | |
| 66 | \begin{verbatim} |
| 67 | <?xml version="1.0"?> |
| 68 | <root xmlns = "http://default-namespace.org/" |
| 69 | xmlns:py = "http://www.python.org/ns/"> |
| 70 | <py:elem1 /> |
| 71 | <elem2 xmlns="" /> |
| 72 | </root> |
| 73 | \end{verbatim} |
| 74 | |
Fred Drake | d79c33a | 2000-09-25 14:14:30 +0000 | [diff] [blame] | 75 | \function{StartElementHandler()} will receive the following strings |
| 76 | for each element: |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 77 | |
| 78 | \begin{verbatim} |
| 79 | http://default-namespace.org/ root |
| 80 | http://www.python.org/ns/ elem1 |
| 81 | elem2 |
| 82 | \end{verbatim} |
| 83 | |
| 84 | \end{funcdesc} |
| 85 | |
| 86 | \class{xmlparser} objects have the following methods: |
| 87 | |
Fred Drake | 2fef3ab | 2000-11-28 06:38:22 +0000 | [diff] [blame] | 88 | \begin{methoddesc}[xmlparser]{Parse}{data\optional{, isfinal}} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 89 | Parses the contents of the string \var{data}, calling the appropriate |
| 90 | handler functions to process the parsed data. \var{isfinal} must be |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 91 | true on the final call to this method. \var{data} can be the empty |
| 92 | string at any time. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 93 | \end{methoddesc} |
| 94 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 95 | \begin{methoddesc}[xmlparser]{ParseFile}{file} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 96 | Parse XML data reading from the object \var{file}. \var{file} only |
| 97 | needs to provide the \method{read(\var{nbytes})} method, returning the |
| 98 | empty string when there's no more data. |
| 99 | \end{methoddesc} |
| 100 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 101 | \begin{methoddesc}[xmlparser]{SetBase}{base} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 102 | Sets the base to be used for resolving relative URIs in system identifiers in |
| 103 | declarations. Resolving relative identifiers is left to the application: |
| 104 | this value will be passed through as the base argument to the |
| 105 | \function{ExternalEntityRefHandler}, \function{NotationDeclHandler}, |
| 106 | and \function{UnparsedEntityDeclHandler} functions. |
| 107 | \end{methoddesc} |
| 108 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 109 | \begin{methoddesc}[xmlparser]{GetBase}{} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 110 | Returns a string containing the base set by a previous call to |
| 111 | \method{SetBase()}, or \code{None} if |
| 112 | \method{SetBase()} hasn't been called. |
| 113 | \end{methoddesc} |
| 114 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 115 | |
Fred Drake | d79c33a | 2000-09-25 14:14:30 +0000 | [diff] [blame] | 116 | \class{xmlparser} objects have the following attributes: |
Andrew M. Kuchling | 0690c86 | 2000-08-17 23:15:21 +0000 | [diff] [blame] | 117 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 118 | \begin{memberdesc}[xmlparser]{returns_unicode} |
Andrew M. Kuchling | 0690c86 | 2000-08-17 23:15:21 +0000 | [diff] [blame] | 119 | If this attribute is set to 1, the handler functions will be passed |
| 120 | Unicode strings. If \member{returns_unicode} is 0, 8-bit strings |
| 121 | containing UTF-8 encoded data will be passed to the handlers. |
Fred Drake | b62966c | 2000-12-07 00:00:21 +0000 | [diff] [blame^] | 122 | \versionchanged[Can be changed at any time to affect the result |
| 123 | type.]{1.6} |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 124 | \end{memberdesc} |
Andrew M. Kuchling | 0690c86 | 2000-08-17 23:15:21 +0000 | [diff] [blame] | 125 | |
| 126 | The following attributes contain values relating to the most recent |
| 127 | error encountered by an \class{xmlparser} object, and will only have |
| 128 | correct values once a call to \method{Parse()} or \method{ParseFile()} |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 129 | has raised a \exception{xml.parsers.expat.error} exception. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 130 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 131 | \begin{memberdesc}[xmlparser]{ErrorByteIndex} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 132 | Byte index at which an error occurred. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 133 | \end{memberdesc} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 134 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 135 | \begin{memberdesc}[xmlparser]{ErrorCode} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 136 | Numeric code specifying the problem. This value can be passed to the |
| 137 | \function{ErrorString()} function, or compared to one of the constants |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 138 | defined in the \module{errors} object. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 139 | \end{memberdesc} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 140 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 141 | \begin{memberdesc}[xmlparser]{ErrorColumnNumber} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 142 | Column number at which an error occurred. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 143 | \end{memberdesc} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 144 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 145 | \begin{memberdesc}[xmlparser]{ErrorLineNumber} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 146 | Line number at which an error occurred. |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 147 | \end{memberdesc} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 148 | |
| 149 | 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] | 150 | \class{xmlparser} object \var{o}, use |
| 151 | \code{\var{o}.\var{handlername} = \var{func}}. \var{handlername} must |
| 152 | be taken from the following list, and \var{func} must be a callable |
| 153 | object accepting the correct number of arguments. The arguments are |
| 154 | all strings, unless otherwise stated. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 155 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 156 | \begin{methoddesc}[xmlparser]{StartElementHandler}{name, attributes} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 157 | Called for the start of every element. \var{name} is a string |
| 158 | containing the element name, and \var{attributes} is a dictionary |
| 159 | mapping attribute names to their values. |
| 160 | \end{methoddesc} |
| 161 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 162 | \begin{methoddesc}[xmlparser]{EndElementHandler}{name} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 163 | Called for the end of every element. |
| 164 | \end{methoddesc} |
| 165 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 166 | \begin{methoddesc}[xmlparser]{ProcessingInstructionHandler}{target, data} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 167 | Called for every processing instruction. |
| 168 | \end{methoddesc} |
| 169 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 170 | \begin{methoddesc}[xmlparser]{CharacterDataHandler}{data} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 171 | Called for character data. |
| 172 | \end{methoddesc} |
| 173 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 174 | \begin{methoddesc}[xmlparser]{UnparsedEntityDeclHandler}{entityName, base, |
| 175 | systemId, publicId, |
| 176 | notationName} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 177 | Called for unparsed (NDATA) entity declarations. |
| 178 | \end{methoddesc} |
| 179 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 180 | \begin{methoddesc}[xmlparser]{NotationDeclHandler}{notationName, base, |
| 181 | systemId, publicId} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 182 | Called for notation declarations. |
| 183 | \end{methoddesc} |
| 184 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 185 | \begin{methoddesc}[xmlparser]{StartNamespaceDeclHandler}{prefix, uri} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 186 | Called when an element contains a namespace declaration. |
| 187 | \end{methoddesc} |
| 188 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 189 | \begin{methoddesc}[xmlparser]{EndNamespaceDeclHandler}{prefix} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 190 | Called when the closing tag is reached for an element |
| 191 | that contained a namespace declaration. |
| 192 | \end{methoddesc} |
| 193 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 194 | \begin{methoddesc}[xmlparser]{CommentHandler}{data} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 195 | Called for comments. |
| 196 | \end{methoddesc} |
| 197 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 198 | \begin{methoddesc}[xmlparser]{StartCdataSectionHandler}{} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 199 | Called at the start of a CDATA section. |
| 200 | \end{methoddesc} |
| 201 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 202 | \begin{methoddesc}[xmlparser]{EndCdataSectionHandler}{} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 203 | Called at the end of a CDATA section. |
| 204 | \end{methoddesc} |
| 205 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 206 | \begin{methoddesc}[xmlparser]{DefaultHandler}{data} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 207 | Called for any characters in the XML document for |
| 208 | which no applicable handler has been specified. This means |
| 209 | characters that are part of a construct which could be reported, but |
| 210 | for which no handler has been supplied. |
| 211 | \end{methoddesc} |
| 212 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 213 | \begin{methoddesc}[xmlparser]{DefaultHandlerExpand}{data} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 214 | This is the same as the \function{DefaultHandler}, |
| 215 | but doesn't inhibit expansion of internal entities. |
| 216 | The entity reference will not be passed to the default handler. |
| 217 | \end{methoddesc} |
| 218 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 219 | \begin{methoddesc}[xmlparser]{NotStandaloneHandler}{} |
Fred Drake | d79c33a | 2000-09-25 14:14:30 +0000 | [diff] [blame] | 220 | Called if the XML document hasn't been declared as being a standalone |
| 221 | document. |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 222 | \end{methoddesc} |
| 223 | |
Fred Drake | efffe8e | 2000-10-29 05:10:30 +0000 | [diff] [blame] | 224 | \begin{methoddesc}[xmlparser]{ExternalEntityRefHandler}{context, base, |
| 225 | systemId, publicId} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 226 | Called for references to external entities. |
| 227 | \end{methoddesc} |
| 228 | |
| 229 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 230 | \subsection{Example \label{expat-example}} |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 231 | |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 232 | The following program defines three handlers that just print out their |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 233 | arguments. |
| 234 | |
| 235 | \begin{verbatim} |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 236 | import xml.parsers.expat |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 237 | |
| 238 | # 3 handler functions |
| 239 | def start_element(name, attrs): |
| 240 | print 'Start element:', name, attrs |
| 241 | def end_element(name): |
| 242 | print 'End element:', name |
| 243 | def char_data(data): |
| 244 | print 'Character data:', repr(data) |
| 245 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 246 | p = xml.parsers.expat.ParserCreate() |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 247 | |
| 248 | p.StartElementHandler = start_element |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 249 | p.EndElementHandler = end_element |
| 250 | p.CharacterDataHandler = char_data |
Andrew M. Kuchling | 6b14eeb | 2000-06-11 02:42:07 +0000 | [diff] [blame] | 251 | |
| 252 | p.Parse("""<?xml version="1.0"?> |
| 253 | <parent id="top"><child1 name="paul">Text goes here</child1> |
| 254 | <child2 name="fred">More text</child2> |
| 255 | </parent>""") |
| 256 | \end{verbatim} |
| 257 | |
| 258 | The output from this program is: |
| 259 | |
| 260 | \begin{verbatim} |
| 261 | Start element: parent {'id': 'top'} |
| 262 | Start element: child1 {'name': 'paul'} |
| 263 | Character data: 'Text goes here' |
| 264 | End element: child1 |
| 265 | Character data: '\012' |
| 266 | Start element: child2 {'name': 'fred'} |
| 267 | Character data: 'More text' |
| 268 | End element: child2 |
| 269 | Character data: '\012' |
| 270 | End element: parent |
| 271 | \end{verbatim} |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 272 | |
| 273 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 274 | \subsection{Expat error constants \label{expat-errors}} |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 275 | \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} |
| 276 | |
| 277 | The following table lists the error constants in the |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 278 | \code{errors} object of the \module{xml.parsers.expat} module. These |
| 279 | constants are useful in interpreting some of the attributes of the |
| 280 | parser object after an error has occurred. |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 281 | |
Fred Drake | 7fbc85c | 2000-09-23 04:47:56 +0000 | [diff] [blame] | 282 | The \code{errors} object has the following attributes: |
Fred Drake | c05cbb0 | 2000-07-05 02:03:34 +0000 | [diff] [blame] | 283 | |
Fred Drake | acab3d6 | 2000-07-11 16:30:30 +0000 | [diff] [blame] | 284 | \begin{datadesc}{XML_ERROR_ASYNC_ENTITY} |
| 285 | \end{datadesc} |
| 286 | |
| 287 | \begin{datadesc}{XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF} |
| 288 | \end{datadesc} |
| 289 | |
| 290 | \begin{datadesc}{XML_ERROR_BAD_CHAR_REF} |
| 291 | \end{datadesc} |
| 292 | |
| 293 | \begin{datadesc}{XML_ERROR_BINARY_ENTITY_REF} |
| 294 | \end{datadesc} |
| 295 | |
| 296 | \begin{datadesc}{XML_ERROR_DUPLICATE_ATTRIBUTE} |
| 297 | An attribute was used more than once in a start tag. |
| 298 | \end{datadesc} |
| 299 | |
| 300 | \begin{datadesc}{XML_ERROR_INCORRECT_ENCODING} |
| 301 | \end{datadesc} |
| 302 | |
| 303 | \begin{datadesc}{XML_ERROR_INVALID_TOKEN} |
| 304 | \end{datadesc} |
| 305 | |
| 306 | \begin{datadesc}{XML_ERROR_JUNK_AFTER_DOC_ELEMENT} |
| 307 | Something other than whitespace occurred after the document element. |
| 308 | \end{datadesc} |
| 309 | |
| 310 | \begin{datadesc}{XML_ERROR_MISPLACED_XML_PI} |
| 311 | \end{datadesc} |
| 312 | |
| 313 | \begin{datadesc}{XML_ERROR_NO_ELEMENTS} |
| 314 | \end{datadesc} |
| 315 | |
| 316 | \begin{datadesc}{XML_ERROR_NO_MEMORY} |
| 317 | Expat was not able to allocate memory internally. |
| 318 | \end{datadesc} |
| 319 | |
| 320 | \begin{datadesc}{XML_ERROR_PARAM_ENTITY_REF} |
| 321 | \end{datadesc} |
| 322 | |
| 323 | \begin{datadesc}{XML_ERROR_PARTIAL_CHAR} |
| 324 | \end{datadesc} |
| 325 | |
| 326 | \begin{datadesc}{XML_ERROR_RECURSIVE_ENTITY_REF} |
| 327 | \end{datadesc} |
| 328 | |
| 329 | \begin{datadesc}{XML_ERROR_SYNTAX} |
| 330 | Some unspecified syntax error was encountered. |
| 331 | \end{datadesc} |
| 332 | |
| 333 | \begin{datadesc}{XML_ERROR_TAG_MISMATCH} |
| 334 | An end tag did not match the innermost open start tag. |
| 335 | \end{datadesc} |
| 336 | |
| 337 | \begin{datadesc}{XML_ERROR_UNCLOSED_TOKEN} |
| 338 | \end{datadesc} |
| 339 | |
| 340 | \begin{datadesc}{XML_ERROR_UNDEFINED_ENTITY} |
| 341 | A reference was made to a entity which was not defined. |
| 342 | \end{datadesc} |
| 343 | |
| 344 | \begin{datadesc}{XML_ERROR_UNKNOWN_ENCODING} |
| 345 | The document encoding is not supported by Expat. |
| 346 | \end{datadesc} |