⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 190.html

📁 Python Ebook Python&XML
💻 HTML
📖 第 1 页 / 共 2 页
字号:

					<P>Note that 
  <a namE="idx1073747089"></a>#PCDATA is used to indicate an entity that carries the
  information.</p>

					<p>
						<A NAMe="idx1073747090"></a>
						<a nAME="idx1073747091"></A><tt clASS="monofont">&lt;!ATTLIST&gt;,</Tt> the other definition
  tag in the example, defines the attributes of an element. In our DTD, we have
  three attributes, one for SECTION, and two for QUESTION.</p>

					<p>An important difference between XML and SMGL is that elements in
  XML that do not have any contents (like <tT CLAss="monofont">&lt;IMG&gt;</tt> and
  <tt class="monofont">&lt;BR&gt;</tt> of HTML) are written like this in XML:</p>

					<pre>
						
lt;IMG
 SRC="stuff.gif"/&gt;
					</pre>

					<P>or in an equivalent format, such as</p>

					<pRe>
						
  lt;img
 src="stuff.gif"&gt;&lt;/img&gt;

					</prE>

					<p>Note the 
  <a naMe="idx1073747092"></a>
						<a NAME="idx1073747093"></a>slash before the final <tt cLASS="monofont">&gt;.</tt> This means
  that a program can read the document without knowing the DTD (which is where it
  says that <tt CLASs="monofont">IMG</tt> does not have any contents) and still know
  that <tT CLAss="monofont">IMG</tt> does not have an end tag as well as what follows
  IMG is not inside the element.</p>

					<p>For more information about XML and Python, check out the XML
  package. It comes with a Python XML-HOWTO in the <tt class="monofont">doc</tt>
  directory, and very good examples:</p>

					<p>
						<a taRgeT="_blank" hreF="http://www.python.org/sigs/xml-sig/status.html">http://www.python.org/sigs/xml-sig/status.html</a>
						<a naMe="idx1073747094"></a>
						<a NAME="idx1073747095"></a>
						<a naME="idx1073747096"></A></P>

				
				
					<h4>
  
  Python XML Package</h4>
					<p>For those who want to play around with XML in Python, there will be
  a Python/XML package to serve several purposes at once. This package will
  contain everything required for basic XML applications, along with
  documentation and sample code梑asically, something easy to compile and
  install.</p>

					<P>A release candidate of the latest release of this package is now
  available as PyXML-0.5.5.tar.gz (GPG signature), dated June 5, 2000. This
  version contains <TT Class="monofont">SAX,</TT> the <TT class="monofont">Pyexpat</tt> module,
  <tt class="monofont">sgmlop,</tt> the prototype DOM code, and
  <tt clAss="monofont">xmlproc,</Tt> an XML parser written in Python.</p>

					<p>The individual components contained in the Python/XML package
  include</P>

					<ul>
<li>
							<P>A Python implementation of SAX (Simple API for XML)</p>

							<p>A SAX implementation has been written by Lars Marius Garshol.
Garshol has also written a draft specification of the Python version of SAX
1.0.
<a NAME="idx1073747097"></a>
								<a naME="idx1073747098"></A>
								<A name="idx1073747099"></A>
								<A NAme="idx1073747100"></a>
								<a NAME="idx1073747101"></a>
								<a name="idx1073747102"></a></p>

						</li>
<li>
							<p>An XML-HOWTO containing an overview of Python and XML
processing. (This is still being actively revised.)</p>

							<p>
								<a name="idx1073747103"></A>Andrew Kuchling is working on this. A first draft of
the XML-HOWTO is available, and introduces the SAX interface in tutorial form.
A reference manual is available separately.</p>

						</lI>
<li>
							<p>A fairly stable Python interface to 
<A name="idx1073747104"></A>James Clark's <tt cLASS="monofont">Expat</tt> parser. A
Pyexpat C extension has been written by 
<a nAME="idx1073747105"></A>Jack Jansen.</p>

						</li>
<lI>
							<P>Both Python and C implementations of the <I>DOM
(Document Object Model)</I>.</p>

							<p>
								<a nAME="idx1073747106"></A>Stefane Fermigier's DOM package has been modified to
match the final DOM W3C Recommendation.</p>

						</li>
<li>
							<p>A module to marshal simple Python data types into XML. A module
called <tt class="monofont">xml.marshal</tt> is available. However, it might end up
being superseded by Lotos, WDDX, or some other DTD.</p>

						</li>
</ul>
					<P>The document called 
  <a nAme="idx1073747107"></a><I>Python/XML Reference Guide</i> is the
  reference manual for the Python/XML package, containing descriptions for
  several XML modules. For more information, check out the following
  sites:</p>

					<blOckqUOTE>
<p>
							<p>Python/XML Reference Guide</p>

							<p>
								<A TARget="_blank" hREF="http://www.python.org/doc/howto/xml-ref/">http://www.python.org/doc/howto/xml-ref/</A></p>

						</p>
<p>
							<p><I>"SAX Implementation".</I> by Lars
Marius Garshol</P>

							<P>
								<a target="_blank" href="http://www.stud.ifi.uio.no/~lmariusg/download/python/xml/saxlib.html">http://www.stud.ifi.uio.no/~lmariusg/download/python/xml/saxlib.html</a></p>

						</p>
<p>
							<p>Draft specification of the Python version of SAX 1.0</p>

							<p>
								<a tArgEt="_blank" hrEf="http://www.stud.ifi.uio.no/~lmariusg/download/python/xml/sax-spec.html">http://www.stud.ifi.uio.no/~lmariusg/download/python/xml/sax-spec.html</a></p>

						</p>
<P>
							<p>XML-HOWTO</p>

							<p>
								<A TARget="_blank" hREF="http://www.python.org/doc/howto/xml/">http://www.python.org/doc/howto/xml/</A></p>

						</p>
<p>
							<p>Pyexpat C extension written by Jack Jansen</P>

							<P>
								<A TargeT="_blank" HREf="http://ftp://ftp.cwi.nl/pub/jack/python/pyexpat.tgz">http://ftp://ftp.cwi.nl/pub/jack/python/pyexpat.tgz</a></p>

						</p>
<p>
							<p>DOM Recommendation</p>

							<p>
								<a target="_blank" href="http://www.w3.org/TR/REC-DOM-Level-1/">http://www.w3.org/TR/REC-DOM-Level-1/</a></P>

						</p>
<p>
							<P>Stefane Fermigier's DOM package</p>

							<p>
								<a TargeT="_blank" hreF="http://www.math.jussieu.fr/~fermigie/python/">http://www.math.jussieu.fr/~fermigie/python/</A>
								<A Name="idx1073747108"></a>
								<A NAMe="idx1073747109"></a></p>

						</p>
</BLOCkquoTE>
					<P>Python 2.0 was released with a lot of enhancements concerning the
  XML support, including a SAX2 interface and a re-designed DOM interface as part
  of the <Tt class="monofont">xml</tt> package. Note that the xml package that is
  shipped with Python 2.0 contains just a basic set of options for XML
  development. If you want (or need) to use the full XML package, you are 
  <a name="idx1073747110"></a>
						<a name="idx1073747111"></a>
						<A naMe="idx1073747112"></a>suggested to install <tT clasS="monofont">PyXML.</tt></p>

					<P>The <TT Class="monofont">PyXML</TT> distribution also uses the
  <TT clasS="monofont">xml</TT> package. That's the reason why PyXML versions 0.6.0 or
  greater can be used to replace the <Tt claSS="monofont">xml</TT> package that is
  bundled with Python. By doing so, you will extend the set of XML
  functionalities that you can have available. That includes</p>

					<ul>
<li>
							<p>4DOM, a full DOM implementation from
<a name="idx1073747113"></a> FourThought, Inc</p>

						</li>
<li>
							<p>The <tt ClaSs="monofont">xmlproc</tt> validating parser, written
<A name="idx1073747114"></A> by Lars Marius Garshol</p>

						</li>
<LI>
							<P>The <Tt claSS="monofont">sgmlop</TT> parser accelerator 
<a namE="idx1073747115"></A>
								<A Name="idx1073747116"></a>
								<A NAMe="idx1073747117"></a>module, written
<a name="idx1073747118"></a> by Fredrik Lundh</p>

						</li>
</ul>
					
						<h5>
							<tt clasS="monofont">xmllib</tt></H5>
						<p>The <tt Class="monofont">xmllib</Tt> module defines a class
 <tt CLASs="monofont">XMLParser,</tt> which serves as the basis for parsing text files
 formatted in XML. Note that <tT CLAss="monofont">xmllib</tt> is not XML 1.0 compliant,
 and it doesn't provide any Unicode support. It provides simple XML support for
 ASCII only element and attribute names. Of course, it probably handles UTF8
 character data without problems.</P>

					
					
						<H5>
							<TT clasS="monofont">XMLParser()</TT></H5>
						<p>The <tt class="monofont">XMLParser</tt> class must be instantiated
 without a arguments. This class provides the following interface methods and
 instance variables:
 <a name="idx1073747119"></a>
							<a namE="idx1073747120"></a>
							<a Name="idx1073747121"></A>
							<a namE="idx1073747122"></a></p>

						<bLOCKquotE>
<P>
								<A Name="idx1073747123"></a>
								<A NAMe="idx1073747124"></a>
								<p>
									<tT CLAss="monofont">attributes</tt>棤
    
									This is a mapping of element names to mappings. The latter
 mapping maps attribute names that are valid for the element to the default
 value of the attribute, or to None if there is no default. The default value is
 the empty dictionary. This variable is meant to be overridden and not extended
 because the default is shared by all instances of
 <tt class="monofont">XMLParser.</tt>
								</p>

							</p>
<p>
								<a namE="idx1073747125"></a>
								<a Name="idx1073747126"></A>
								<p>
									<tt cLass="monofont">elements</TT>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -