diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libpyexpat.tex | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/Doc/lib/libpyexpat.tex b/Doc/lib/libpyexpat.tex index fafdfcb..1a0a1c8 100644 --- a/Doc/lib/libpyexpat.tex +++ b/Doc/lib/libpyexpat.tex @@ -32,10 +32,14 @@ provide access to the Expat parser. Direct use of the This module provides one exception and one type object: -\begin{excdesc}{error} +\begin{excdesc}{ExpatError} The exception raised when Expat reports an error. \end{excdesc} +\begin{excdesc}{error} + Alias for \exception{ExpatError}. +\end{excdesc} + \begin{datadesc}{XMLParserType} The type of the return values from the \function{ParserCreate()} function. @@ -126,6 +130,14 @@ Returns a string containing the base set by a previous call to \method{SetBase()} hasn't been called. \end{methoddesc} +\begin{methoddesc}[xmlparser]{GetInputContext}{} +Returns the input data that generated the current event as a string. +The data is in the encoding of the entity which contains the text. +When called while an event handler is not active, the return value is +\code{None}. +\versionadded{2.1} +\end{methoddesc} + \begin{methoddesc}[xmlparser]{ExternalEntityParserCreate}{context\optional{, encoding}} Create a ``child'' parser which can be used to parse an external @@ -385,6 +397,32 @@ If this handler is not provided, external entities are reported by the \end{methoddesc} +\subsection{ExpatError Exceptions \label{expaterror-objects}} +\sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org} + +\exception{ExpatError} exceptions have a number of interesting +attributes: + +\begin{memberdesc}[ExpatError]{code} + Expat's internal error number for the specific error. This will + match one of the constants defined in the \code{errors} object from + this module. + \versionadded{2.1} +\end{memberdesc} + +\begin{memberdesc}[ExpatError]{lineno} + Line number on which the error was detected. The first line is + numbered \code{1}. + \versionadded{2.1} +\end{memberdesc} + +\begin{memberdesc}[ExpatError]{offset} + Character offset into the line where the error occurred. The first + column is numbered \code{0}. + \versionadded{2.1} +\end{memberdesc} + + \subsection{Example \label{expat-example}} The following program defines three handlers that just print out their @@ -493,10 +531,10 @@ The model must occur zero or more times, as for \code{A*}. \subsection{Expat error constants \label{expat-errors}} \sectionauthor{A.M. Kuchling}{amk1@bigfoot.com} -The following table lists the error constants in the -\code{errors} object of the \module{xml.parsers.expat} module. These -constants are useful in interpreting some of the attributes of the -parser object after an error has occurred. +The following constants are provided in the \code{errors} object of +the \refmodule{xml.parsers.expat} module. These constants are useful +in interpreting some of the attributes of the \exception{ExpatError} +exception objects raised when an error has occurred. The \code{errors} object has the following attributes: |