Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 1 | \section{Standard Module \module{xmllib}} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 2 | % Author: Sjoerd Mullender |
| 3 | \label{module-xmllib} |
| 4 | \stmodindex{xmllib} |
| 5 | \index{XML} |
| 6 | |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 7 | This module defines a class \class{XMLParser} which serves as the basis |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 8 | for parsing text files formatted in XML (eXtended Markup Language). |
| 9 | |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 10 | \begin{classdesc}{XMLParser}{} |
| 11 | The \class{XMLParser} class must be instantiated without arguments. |
| 12 | \end{classdesc} |
| 13 | |
| 14 | This class provides the following interface methods: |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 15 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 16 | \begin{methoddesc}{reset}{} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 17 | Reset the instance. Loses all unprocessed data. This is called |
| 18 | implicitly at the instantiation time. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 19 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 20 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 21 | \begin{methoddesc}{setnomoretags}{} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 22 | Stop processing tags. Treat all following input as literal input |
| 23 | (CDATA). |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 24 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 25 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 26 | \begin{methoddesc}{setliteral}{} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 27 | Enter literal mode (CDATA mode). |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 28 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 29 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 30 | \begin{methoddesc}{feed}{data} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 31 | Feed some text to the parser. It is processed insofar as it consists |
| 32 | of complete elements; incomplete data is buffered until more data is |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 33 | fed or \method{close()} is called. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 34 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 35 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 36 | \begin{methoddesc}{close}{} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 37 | Force processing of all buffered data as if it were followed by an |
| 38 | end-of-file mark. This method may be redefined by a derived class to |
| 39 | define additional processing at the end of the input, but the |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 40 | redefined version should always call \method{close()}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 41 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 42 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 43 | \begin{methoddesc}{translate_references}{data} |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 44 | Translate all entity and character references in \var{data} and |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 45 | returns the translated string. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 46 | \end{methoddesc} |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 47 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 48 | \begin{methoddesc}{handle_xml}{encoding, standalone} |
| 49 | This method is called when the \samp{<?xml ...?>} tag is processed. |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 50 | The arguments are the values of the encoding and standalone attributes |
| 51 | in the tag. Both encoding and standalone are optional. The values |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 52 | passed to \method{handle_xml()} default to \code{None} and the string |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 53 | \code{'no'} respectively. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 54 | \end{methoddesc} |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 55 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 56 | \begin{methoddesc}{handle_doctype}{tag, data} |
| 57 | This method is called when the \samp{<!DOCTYPE...>} tag is processed. |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 58 | The arguments are the name of the root element and the uninterpreted |
| 59 | contents of the tag, starting after the white space after the name of |
| 60 | the root element. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 61 | \end{methoddesc} |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 62 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 63 | \begin{methoddesc}{handle_starttag}{tag, method, attributes} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 64 | This method is called to handle start tags for which a |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 65 | \method{start_\var{tag}()} method has been defined. The \var{tag} |
| 66 | argument is the name of the tag, and the \var{method} argument is the |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 67 | bound method which should be used to support semantic interpretation |
| 68 | of the start tag. The \var{attributes} argument is a dictionary of |
| 69 | attributes, the key being the \var{name} and the value being the |
| 70 | \var{value} of the attribute found inside the tag's \code{<>} brackets. |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 71 | Character and entity references in the \var{value} have |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 72 | been interpreted. For instance, for the tag |
| 73 | \code{<A HREF="http://www.cwi.nl/">}, this method would be called as |
Fred Drake | b0744c5 | 1997-12-29 19:59:38 +0000 | [diff] [blame] | 74 | \code{handle_starttag('A', self.start_A, \{'HREF': 'http://www.cwi.nl/'\})}. |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 75 | The base implementation simply calls \var{method} with \var{attributes} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 76 | as the only argument. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 77 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 78 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 79 | \begin{methoddesc}{handle_endtag}{tag, method} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 80 | This method is called to handle endtags for which an |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 81 | \method{end_\var{tag}()} method has been defined. The \var{tag} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 82 | argument is the name of the tag, and the |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 83 | \var{method} argument is the bound method which should be used to |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 84 | support semantic interpretation of the end tag. If no |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 85 | \method{end_\var{tag}()} method is defined for the closing element, this |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 86 | handler is not called. The base implementation simply calls |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 87 | \var{method}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 88 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 89 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 90 | \begin{methoddesc}{handle_data}{data} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 91 | This method is called to process arbitrary data. It is intended to be |
| 92 | overridden by a derived class; the base class implementation does |
| 93 | nothing. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 94 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 95 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 96 | \begin{methoddesc}{handle_charref}{ref} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 97 | This method is called to process a character reference of the form |
Fred Drake | 7f6e2c4 | 1998-02-13 14:38:23 +0000 | [diff] [blame] | 98 | \samp{\&\#\var{ref};}. \var{ref} can either be a decimal number, |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 99 | or a hexadecimal number when preceded by an \character{x}. |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 100 | In the base implementation, \var{ref} must be a number in the |
| 101 | range 0-255. It translates the character to \ASCII{} and calls the |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 102 | method \method{handle_data()} with the character as argument. If |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 103 | \var{ref} is invalid or out of range, the method |
| 104 | \code{unknown_charref(\var{ref})} is called to handle the error. A |
| 105 | subclass must override this method to provide support for character |
| 106 | references outside of the \ASCII{} range. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 107 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 108 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 109 | \begin{methoddesc}{handle_entityref}{ref} |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 110 | This method is called to process a general entity reference of the |
| 111 | form \samp{\&\var{ref};} where \var{ref} is an general entity |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 112 | reference. It looks for \var{ref} in the instance (or class) |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 113 | variable \member{entitydefs} which should be a mapping from entity |
| 114 | names to corresponding translations. |
| 115 | If a translation is found, it calls the method \method{handle_data()} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 116 | with the translation; otherwise, it calls the method |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 117 | \code{unknown_entityref(\var{ref})}. The default \member{entitydefs} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 118 | defines translations for \code{\&}, \code{\&apos}, \code{\>}, |
| 119 | \code{\<}, and \code{\"}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 120 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 121 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 122 | \begin{methoddesc}{handle_comment}{comment} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 123 | This method is called when a comment is encountered. The |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 124 | \var{comment} argument is a string containing the text between the |
Fred Drake | 7f6e2c4 | 1998-02-13 14:38:23 +0000 | [diff] [blame] | 125 | \samp{<!--} and \samp{-->} delimiters, but not the delimiters |
| 126 | themselves. For example, the comment \samp{<!--text-->} will |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 127 | cause this method to be called with the argument \code{'text'}. The |
| 128 | default method does nothing. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 129 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 130 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 131 | \begin{methoddesc}{handle_cdata}{data} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 132 | This method is called when a CDATA element is encountered. The |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 133 | \var{data} argument is a string containing the text between the |
Fred Drake | 7f6e2c4 | 1998-02-13 14:38:23 +0000 | [diff] [blame] | 134 | \samp{<![CDATA[} and \samp{]]>} delimiters, but not the delimiters |
| 135 | themselves. For example, the entity \samp{<![CDATA[text]]>} will |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 136 | cause this method to be called with the argument \code{'text'}. The |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 137 | default method does nothing, and is intended to be overridden. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 138 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 139 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 140 | \begin{methoddesc}{handle_proc}{name, data} |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 141 | This method is called when a processing instruction (PI) is |
| 142 | encountered. The \var{name} is the PI target, and the \var{data} |
| 143 | argument is a string containing the text between the PI target and the |
| 144 | closing delimiter, but not the delimiter itself. For example, the |
| 145 | instruction \samp{<?XML text?>} will cause this method to be called |
| 146 | with the arguments \code{'XML'} and \code{'text'}. The default method |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 147 | does nothing. Note that if a document starts with \samp{<?xml |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 148 | ...?>}, \method{handle_xml()} is called to handle it. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 149 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 150 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 151 | \begin{methoddesc}{handle_special}{data} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 152 | This method is called when a declaration is encountered. The |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 153 | \var{data} argument is a string containing the text between the |
Fred Drake | 7f6e2c4 | 1998-02-13 14:38:23 +0000 | [diff] [blame] | 154 | \samp{<!} and \samp{>} delimiters, but not the delimiters |
| 155 | themselves. For example, the entity \samp{<!ENTITY text>} will |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 156 | cause this method to be called with the argument \code{'ENTITY text'}. The |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 157 | default method does nothing. Note that \samp{<!DOCTYPE ...>} is |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 158 | handled separately if it is located at the start of the document. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 159 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 160 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 161 | \begin{methoddesc}{syntax_error}{message} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 162 | This method is called when a syntax error is encountered. The |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 163 | \var{message} is a description of what was wrong. The default method |
| 164 | raises a \exception{RuntimeError} exception. If this method is |
| 165 | overridden, it is permissable for it to return. This method is only |
| 166 | called when the error can be recovered from. Unrecoverable errors |
| 167 | raise a \exception{RuntimeError} without first calling |
| 168 | \method{syntax_error()}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 169 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 170 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 171 | \begin{methoddesc}{unknown_starttag}{tag, attributes} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 172 | This method is called to process an unknown start tag. It is intended |
| 173 | to be overridden by a derived class; the base class implementation |
| 174 | does nothing. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 175 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 176 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 177 | \begin{methoddesc}{unknown_endtag}{tag} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 178 | This method is called to process an unknown end tag. It is intended |
| 179 | to be overridden by a derived class; the base class implementation |
| 180 | does nothing. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 181 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 182 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 183 | \begin{methoddesc}{unknown_charref}{ref} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 184 | This method is called to process unresolvable numeric character |
| 185 | references. It is intended to be overridden by a derived class; the |
| 186 | base class implementation does nothing. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 187 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 188 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 189 | \begin{methoddesc}{unknown_entityref}{ref} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 190 | This method is called to process an unknown entity reference. It is |
| 191 | intended to be overridden by a derived class; the base class |
| 192 | implementation does nothing. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 193 | \end{methoddesc} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 194 | |
| 195 | Apart from overriding or extending the methods listed above, derived |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 196 | classes may also define methods and variables of the following form to |
| 197 | define processing of specific tags. Tag names in the input stream are |
| 198 | case dependent; the \var{tag} occurring in method names must be in the |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 199 | correct case: |
| 200 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 201 | \begin{methoddescni}{start_\var{tag}}{attributes} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 202 | This method is called to process an opening tag \var{tag}. The |
| 203 | \var{attributes} argument has the same meaning as described for |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 204 | \method{handle_starttag()} above. In fact, the base implementation of |
| 205 | \method{handle_starttag()} calls this method. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 206 | \end{methoddescni} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 207 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 208 | \begin{methoddescni}{end_\var{tag}}{} |
Guido van Rossum | a10768a | 1997-11-18 15:11:22 +0000 | [diff] [blame] | 209 | This method is called to process a closing tag \var{tag}. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 210 | \end{methoddescni} |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 211 | |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 212 | \begin{memberdescni}{\var{tag}_attributes} |
| 213 | If a class or instance variable \member{\var{tag}_attributes} exists, it |
Guido van Rossum | 02505e4 | 1998-01-29 14:55:24 +0000 | [diff] [blame] | 214 | should be a list or a dictionary. If a list, the elements of the list |
| 215 | are the valid attributes for the element \var{tag}; if a dictionary, |
| 216 | the keys are the valid attributes for the element \var{tag}, and the |
| 217 | values the default values of the attributes, or \code{None} if there |
| 218 | is no default. |
| 219 | In addition to the attributes that were present in the tag, the |
Fred Drake | 3b5da76 | 1998-03-12 15:33:05 +0000 | [diff] [blame] | 220 | attribute dictionary that is passed to \method{handle_starttag()} and |
| 221 | \method{unknown_starttag()} contains values for all attributes that |
| 222 | have a default value. |
Fred Drake | fc57619 | 1998-04-04 07:15:02 +0000 | [diff] [blame] | 223 | \end{memberdescni} |