annotate Doc/lib/xmlsaxutils.tex @ 21467:4e35fa5d5708 legacy-trunk

Add documentation for the help() built-in; contributed by Ka-Ping Yee. This is part of SF patch #494622.
author Fred Drake <fdrake@acm.org>
date Tue, 18 Dec 2001 16:31:08 +0000
parents 3537062b3dc1
children 7049268f252d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15183
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 \section{\module{xml.sax.saxutils} ---
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 SAX Utilities}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
4 \declaremodule{standard}{xml.sax.saxutils}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
5 \modulesynopsis{Convenience functions and classes for use with SAX.}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
6 \sectionauthor{Martin v. L\"owis}{loewis@informatik.hu-berlin.de}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
7 \moduleauthor{Lars Marius Garshol}{larsga@garshol.priv.no}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
8
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
9 \versionadded{2.0}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
10
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
11
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
12 The module \module{xml.sax.saxutils} contains a number of classes and
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13 functions that are commonly useful when creating SAX applications,
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
14 either in direct use, or as base classes.
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
15
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16 \begin{funcdesc}{escape}{data\optional{, entities}}
18740
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
17 Escape \character{\&}, \character{<}, and \character{>} in a string
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
18 of data.
15183
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
19
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
20 You can escape other strings of data by passing a dictionary as the
18740
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
21 optional \var{entities} parameter. The keys and values must all be
15183
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
22 strings; each key will be replaced with its corresponding value.
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
23 \end{funcdesc}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
24
18740
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
25 \begin{funcdesc}{quoteattr}{data\optional{, entities}}
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
26 Similar to \function{escape()}, but also prepares \var{data} to be
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
27 used as an attribute value. The return value is a quoted version of
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
28 \var{data} with any additional required replacements.
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
29 \function{quoteattr()} will select a quote character based on the
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
30 content of \var{data}, attempting to avoid encoding any quote
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
31 characters in the string. If both single- and double-quote
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
32 characters are already in \var{data}, the double-quote characters
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
33 will be encoded and \var{data} will be wrapped in doule-quotes. The
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
34 resulting string can be used directly as an attribute value:
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
35
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
36 \begin{verbatim}
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
37 >>> print "<element attr=%s>" % quoteattr("ab ' cd \" ef")
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
38 <element attr="ab ' cd &quot; ef">
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
39 \end{verbatim}
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
40
19159
3537062b3dc1 Add a note that the quoteattr() function is useful for HTML and SGML
Fred Drake <fdrake@acm.org>
parents: 18740
diff changeset
41 This function is useful when generating attribute values for HTML or
3537062b3dc1 Add a note that the quoteattr() function is useful for HTML and SGML
Fred Drake <fdrake@acm.org>
parents: 18740
diff changeset
42 any SGML using the reference concrete syntax.
18740
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
43 \versionadded{2.2}
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
44 \end{funcdesc}
1aa7e219f52d Added function xml.sax.saxutils.quoteattr().
Fred Drake <fdrake@acm.org>
parents: 15183
diff changeset
45
15183
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
46 \begin{classdesc}{XMLGenerator}{\optional{out\optional{, encoding}}}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
47 This class implements the \class{ContentHandler} interface by
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
48 writing SAX events back into an XML document. In other words, using
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
49 an \class{XMLGenerator} as the content handler will reproduce the
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
50 original document being parsed. \var{out} should be a file-like
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
51 object which will default to \var{sys.stdout}. \var{encoding} is the
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
52 encoding of the output stream which defaults to \code{'iso-8859-1'}.
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
53 \end{classdesc}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
54
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
55 \begin{classdesc}{XMLFilterBase}{base}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
56 This class is designed to sit between an \class{XMLReader} and the
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
57 client application's event handlers. By default, it does nothing
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
58 but pass requests up to the reader and events on to the handlers
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
59 unmodified, but subclasses can override specific methods to modify
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
60 the event stream or the configuration requests as they pass through.
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
61 \end{classdesc}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
62
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
63 \begin{funcdesc}{prepare_input_source}{source\optional{, base}}
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
64 This function takes an input source and an optional base URL and
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
65 returns a fully resolved \class{InputSource} object ready for
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
66 reading. The input source can be given as a string, a file-like
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
67 object, or an \class{InputSource} object; parsers will use this
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
68 function to implement the polymorphic \var{source} argument to their
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
69 \method{parse()} method.
4d2187264cfa Massive addition of SAX documentation from Martin von Loewis
Fred Drake <fdrake@acm.org>
parents:
diff changeset
70 \end{funcdesc}