summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-07-19 16:10:15 (GMT)
committerFred Drake <fdrake@acm.org>2001-07-19 16:10:15 (GMT)
commitacd32d3be542987078c65a8a34d7844cfa7ebbe8 (patch)
treee3ff8c129dd9cc8d18a9cdf06b0fab20943554bb /Doc
parent3c033230ec2f81c9d61ba1b1f19a99f8bf4f4bd3 (diff)
downloadcpython-acd32d3be542987078c65a8a34d7844cfa7ebbe8.zip
cpython-acd32d3be542987078c65a8a34d7844cfa7ebbe8.tar.gz
cpython-acd32d3be542987078c65a8a34d7844cfa7ebbe8.tar.bz2
Added function xml.sax.saxutils.quoteattr().
This closes SF bug #440351. It should not be moved to Python 2.1.1.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/xmlsaxutils.tex24
1 files changed, 22 insertions, 2 deletions
diff --git a/Doc/lib/xmlsaxutils.tex b/Doc/lib/xmlsaxutils.tex
index 2ff1471..0048485 100644
--- a/Doc/lib/xmlsaxutils.tex
+++ b/Doc/lib/xmlsaxutils.tex
@@ -14,13 +14,33 @@ functions that are commonly useful when creating SAX applications,
either in direct use, or as base classes.
\begin{funcdesc}{escape}{data\optional{, entities}}
- Escape \&, <, and > in a string of data.
+ Escape \character{\&}, \character{<}, and \character{>} in a string
+ of data.
You can escape other strings of data by passing a dictionary as the
- optional entities parameter. The keys and values must all be
+ optional \var{entities} parameter. The keys and values must all be
strings; each key will be replaced with its corresponding value.
\end{funcdesc}
+\begin{funcdesc}{quoteattr}{data\optional{, entities}}
+ Similar to \function{escape()}, but also prepares \var{data} to be
+ used as an attribute value. The return value is a quoted version of
+ \var{data} with any additional required replacements.
+ \function{quoteattr()} will select a quote character based on the
+ content of \var{data}, attempting to avoid encoding any quote
+ characters in the string. If both single- and double-quote
+ characters are already in \var{data}, the double-quote characters
+ will be encoded and \var{data} will be wrapped in doule-quotes. The
+ resulting string can be used directly as an attribute value:
+
+\begin{verbatim}
+>>> print "<element attr=%s>" % quoteattr("ab ' cd \" ef")
+<element attr="ab ' cd &quot; ef">
+\end{verbatim}
+
+ \versionadded{2.2}
+\end{funcdesc}
+
\begin{classdesc}{XMLGenerator}{\optional{out\optional{, encoding}}}
This class implements the \class{ContentHandler} interface by
writing SAX events back into an XML document. In other words, using