?? module-xmllib.html
字號:
<P>
<dl><dt><b><a name='l2h-2750'><tt class='method'>handle_charref</tt></a></b> (<var>ref</var>)
<dd>
This method is called to process a character reference of the form
"<tt class="samp">&#<var>ref</var>;</tt>". <var>ref</var> can either be a decimal number,
or a hexadecimal number when preceded by an "<tt class="character">x</tt>".
In the base implementation, <var>ref</var> must be a number in the
range 0-255. It translates the character to ASCII and calls the
method <tt class="method">handle_data()</tt> with the character as argument. If
<var>ref</var> is invalid or out of range, the method
<code>unknown_charref(<var>ref</var>)</code> is called to handle the error. A
subclass must override this method to provide support for character
references outside of the ASCII range.
</dl>
<P>
<dl><dt><b><a name='l2h-2751'><tt class='method'>handle_comment</tt></a></b> (<var>comment</var>)
<dd>
This method is called when a comment is encountered. The
<var>comment</var> argument is a string containing the text between the
"<tt class="samp"><!-</tt>" and "<tt class="samp">-></tt>" delimiters, but not the delimiters
themselves. For example, the comment "<tt class="samp"><!-text-></tt>" will
cause this method to be called with the argument <code>'text'</code>. The
default method does nothing.
</dl>
<P>
<dl><dt><b><a name='l2h-2752'><tt class='method'>handle_cdata</tt></a></b> (<var>data</var>)
<dd>
This method is called when a CDATA element is encountered. The
<var>data</var> argument is a string containing the text between the
"<tt class="samp"><![CDATA[</tt>" and "<tt class="samp">]]></tt>" delimiters, but not the delimiters
themselves. For example, the entity "<tt class="samp"><![CDATA[text]]></tt>" will
cause this method to be called with the argument <code>'text'</code>. The
default method does nothing, and is intended to be overridden.
</dl>
<P>
<dl><dt><b><a name='l2h-2753'><tt class='method'>handle_proc</tt></a></b> (<var>name, data</var>)
<dd>
This method is called when a processing instruction (PI) is
encountered. The <var>name</var> is the PI target, and the <var>data</var>
argument is a string containing the text between the PI target and the
closing delimiter, but not the delimiter itself. For example, the
instruction "<tt class="samp"><?XML text?></tt>" will cause this method to be called
with the arguments <code>'XML'</code> and <code>'text'</code>. The default method
does nothing. Note that if a document starts with "<tt class="samp"><?xml
..?></tt>", <tt class="method">handle_xml()</tt> is called to handle it.
</dl>
<P>
<dl><dt><b><a name='l2h-2754'><tt class='method'>handle_special</tt></a></b> (<var>data</var>)
<dd>
This method is called when a declaration is encountered. The
<var>data</var> argument is a string containing the text between the
"<tt class="samp"><!</tt>" and "<tt class="samp">></tt>" delimiters, but not the delimiters
themselves. For example, the entity
declaration "<tt class="samp"><!ENTITY text></tt>" will cause this method to be called
with the argument <code>'ENTITY text'</code>. The default method does
nothing. Note that "<tt class="samp"><!DOCTYPE ...></tt>" is handled separately if it
is located at the start of the document.
</dl>
<P>
<dl><dt><b><a name='l2h-2755'><tt class='method'>syntax_error</tt></a></b> (<var>message</var>)
<dd>
This method is called when a syntax error is encountered. The
<var>message</var> is a description of what was wrong. The default method
raises a <tt class="exception">RuntimeError</tt> exception. If this method is
overridden, it is permissible for it to return. This method is only
called when the error can be recovered from. Unrecoverable errors
raise a <tt class="exception">RuntimeError</tt> without first calling
<tt class="method">syntax_error()</tt>.
</dl>
<P>
<dl><dt><b><a name='l2h-2756'><tt class='method'>unknown_starttag</tt></a></b> (<var>tag, attributes</var>)
<dd>
This method is called to process an unknown start tag. It is intended
to be overridden by a derived class; the base class implementation
does nothing.
</dl>
<P>
<dl><dt><b><a name='l2h-2757'><tt class='method'>unknown_endtag</tt></a></b> (<var>tag</var>)
<dd>
This method is called to process an unknown end tag. It is intended
to be overridden by a derived class; the base class implementation
does nothing.
</dl>
<P>
<dl><dt><b><a name='l2h-2758'><tt class='method'>unknown_charref</tt></a></b> (<var>ref</var>)
<dd>
This method is called to process unresolvable numeric character
references. It is intended to be overridden by a derived class; the
base class implementation does nothing.
</dl>
<P>
<dl><dt><b><a name='l2h-2759'><tt class='method'>unknown_entityref</tt></a></b> (<var>ref</var>)
<dd>
This method is called to process an unknown entity reference. It is
intended to be overridden by a derived class; the base class
implementation calls <tt class="method">syntax_error()</tt> to signal an error.
</dl>
<P>
<div class='seealso'>
<p class='heading'><b>See Also:</b></p>
<dl compact class="seetitle">
<dt><em class="citetitle"><a href="javascript:if(confirm('http://www.w3.org/TR/REC-xml \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.w3.org/TR/REC-xml'" tppabs="http://www.w3.org/TR/REC-xml"
>Extensible Markup Language
(XML) 1.0 <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
></a></em>
<dd>The XML specification, published by the World
Wide Web Consortium (W3C), defines the syntax and
processor requirements for XML. References to additional
material on XML, including translations of the
specification, are available at
<a class="url" href="javascript:if(confirm('http://www.w3.org/XML/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.w3.org/XML/'" tppabs="http://www.w3.org/XML/">http://www.w3.org/XML/ <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
></a>.
</dl>
<P>
<dl compact class="seetitle">
<dt><em class="citetitle"><a href="javascript:if(confirm('http://www.python.org/topics/xml/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.python.org/topics/xml/'" tppabs="http://www.python.org/topics/xml/"
>Python and XML
Processing <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
></a></em>
<dd>The Python XML Topic Guide provides a great
deal of information on using XML from Python and links to
other sources of information on XML.
</dl>
<P>
<dl compact class="seetitle">
<dt><em class="citetitle"><a href="javascript:if(confirm('http://www.python.org/sigs/xml-sig/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.python.org/sigs/xml-sig/'" tppabs="http://www.python.org/sigs/xml-sig/"
>SIG for XML
Processing in Python <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
></a></em>
<dd>The Python XML Special Interest
Group is developing substantial support for processing XML
from Python.
</dl>
</div>
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
<DT><A NAME="foot32466">...
arguments.</A><A NAME="foot32466"
href="module-xmllib.html#tex2html58" tppabs="http://www.python.org/doc/current/lib/module-xmllib.html#tex2html58"><SUP>13.1</SUP></A>
<DD>Actually, a number of keyword arguments are
recognized which influence the parser to accept certain non-standard
constructs. The following keyword arguments are currently
recognized. The defaults for all of these is <code>0</code> (false) except
for the last one for which the default is <code>1</code> (true).
<var>accept_unquoted_attributes</var> (accept certain attribute values
without requiring quotes), <var>accept_missing_endtag_name</var> (accept
end tags that look like <code></></code>), <var>map_case</var> (map upper case to
lower case in tags and attributes), <var>accept_utf8</var> (allow UTF-8
characters in input; this is required according to the XML standard,
but Python does not as yet deal properly with these characters, so
this is not the default), <var>translate_attribute_references</var> (don't
attempt to translate character and entity references in attribute values).
</DL>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL>
<LI><A NAME="tex2html5030"
href="xml-namespace.html" tppabs="http://www.python.org/doc/current/lib/xml-namespace.html">13.9.1 XML Namespaces </A>
</UL>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="attributes-ns-impl-objects.html" tppabs="http://www.python.org/doc/current/lib/attributes-ns-impl-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="xml-namespace.html" tppabs="http://www.python.org/doc/current/lib/xml-namespace.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="attributes-ns-impl-objects.html" tppabs="http://www.python.org/doc/current/lib/attributes-ns-impl-objects.html">13.8.6 AttributesNSImpl Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="markup.html" tppabs="http://www.python.org/doc/current/lib/markup.html">13. Structured Markup Processing</A>
<b class="navlabel">Next:</b> <a class="sectref" href="xml-namespace.html" tppabs="http://www.python.org/doc/current/lib/xml-namespace.html">13.9.1 XML Namespaces</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -