Team Ai
Apppublic

parthtamu/rag-code-assistant

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
xml.sax.html522 linesDownload Raw Back to docs
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4  <head>5    <meta charset="utf-8" />6    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="xml.sax — Support for SAX2 parsers" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/xml.sax.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="Source code: Lib/xml/sax/__init__.py The xml.sax package provides a number of modules which implement the Simple API for XML (SAX) interface for Python. The package itself provides the SAX exceptio..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_xml.sax_80b36dd0.png" />15<meta property="og:image:alt" content="Source code: Lib/xml/sax/__init__.py The xml.sax package provides a number of modules which implement the Simple API for XML (SAX) interface for Python. The package itself provides the SAX exceptio..." />16<meta name="description" content="Source code: Lib/xml/sax/__init__.py The xml.sax package provides a number of modules which implement the Simple API for XML (SAX) interface for Python. The package itself provides the SAX exceptio..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20    <title>xml.sax — Support for SAX2 parsers &#8212; Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21    22    <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23    <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24    <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25    <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26    <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27    28    <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29    <script src="../_static/doctools.js?v=9bcbadda"></script>30    <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31    <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32    33    <script src="../_static/sidebar.js"></script>34    35    <link rel="search" type="application/opensearchdescription+xml"36          title="Search within Python 3.15.0a6 documentation"37          href="../_static/opensearch.xml"/>38    <link rel="author" title="About these documents" href="../about.html" />39    <link rel="index" title="Index" href="../genindex.html" />40    <link rel="search" title="Search" href="../search.html" />41    <link rel="copyright" title="Copyright" href="../copyright.html" />42    <link rel="next" title="xml.sax.handler — Base classes for SAX handlers" href="xml.sax.handler.html" />43    <link rel="prev" title="xml.dom.pulldom — Support for building partial DOM trees" href="xml.dom.pulldom.html" />44    45      46      <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47      48      <link rel="canonical" href="https://docs.python.org/3/library/xml.sax.html">49      50    51 52    53    <style>54      @media only screen {55        table.full-width-table {56            width: 100%;57        }58      }59    </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61    <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62            <script type="text/javascript" src="../_static/copybutton.js"></script>63            <script type="text/javascript" src="../_static/menu.js"></script>64            <script type="text/javascript" src="../_static/search-focus.js"></script>65            <script type="text/javascript" src="../_static/themetoggle.js"></script> 66            <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67            <meta name="readthedocs-addons-api-version" content="1">68 69  </head>70<body>71<div class="mobile-nav">72    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74    <nav class="nav-content" role="navigation">75        <label for="menuToggler" class="toggler__label">76            <span></span>77        </label>78        <span class="nav-items-wrapper">79            <a href="https://www.python.org/" class="nav-logo">80                <img src="../_static/py.svg" alt="Python logo">81            </a>82            <span class="version_switcher_placeholder"></span>83            <form role="search" class="search" action="../search.html" method="get">84                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85                    <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86                </svg>87                <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88                <input type="submit" value="Go">89            </form>90        </span>91    </nav>92    <div class="menu-wrapper">93        <nav class="menu" role="navigation" aria-label="main navigation">94            <div class="language_switcher_placeholder"></div>95            96<label class="theme-selector-label">97    Theme98    <select class="theme-selector" oninput="activateTheme(this.value)">99        <option value="auto" selected>Auto</option>100        <option value="light">Light</option>101        <option value="dark">Dark</option>102    </select>103</label>104  <div>105    <h3><a href="../contents.html">Table of Contents</a></h3>106    <ul>107<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code> — Support for SAX2 parsers</a><ul>108<li><a class="reference internal" href="#saxexception-objects">SAXException Objects</a></li>109</ul>110</li>111</ul>112 113  </div>114  <div>115    <h4>Previous topic</h4>116    <p class="topless"><a href="xml.dom.pulldom.html"117                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.pulldom</span></code> — Support for building partial DOM trees</a></p>118  </div>119  <div>120    <h4>Next topic</h4>121    <p class="topless"><a href="xml.sax.handler.html"122                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.handler</span></code> — Base classes for SAX handlers</a></p>123  </div>124  <script>125    document.addEventListener('DOMContentLoaded', () => {126        const title = document.querySelector('meta[property="og:title"]').content;127        const elements = document.querySelectorAll('.improvepage');128        const pageurl = window.location.href.split('?')[0];129        elements.forEach(element => {130            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));131            url.searchParams.set('pagetitle', title);132            url.searchParams.set('pageurl', pageurl);133            url.searchParams.set('pagesource', "library/xml.sax.rst");134            element.href = url.toString();135        });136    });137  </script>138  <div role="note" aria-label="source link">139    <h3>This page</h3>140    <ul class="this-page-menu">141      <li><a href="../bugs.html">Report a bug</a></li>142      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>143      <li>144        <a href="https://github.com/python/cpython/blob/main/Doc/library/xml.sax.rst?plain=1"145            rel="nofollow">Show source146        </a>147      </li>148      149    </ul>150  </div>151        </nav>152    </div>153</div>154 155  156    <div class="related" role="navigation" aria-label="Related">157      <h3>Navigation</h3>158      <ul>159        <li class="right" style="margin-right: 10px">160          <a href="../genindex.html" title="General Index"161             accesskey="I">index</a></li>162        <li class="right" >163          <a href="../py-modindex.html" title="Python Module Index"164             >modules</a> |</li>165        <li class="right" >166          <a href="xml.sax.handler.html" title="xml.sax.handler — Base classes for SAX handlers"167             accesskey="N">next</a> |</li>168        <li class="right" >169          <a href="xml.dom.pulldom.html" title="xml.dom.pulldom — Support for building partial DOM trees"170             accesskey="P">previous</a> |</li>171 172          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>173          <li><a href="https://www.python.org/">Python</a> &#187;</li>174          <li class="switchers">175            <div class="language_switcher_placeholder"></div>176            <div class="version_switcher_placeholder"></div>177          </li>178          <li>179              180          </li>181    <li id="cpython-language-and-version">182      <a href="../index.html">3.15.0a6 Documentation</a> &#187;183    </li>184 185          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>186          <li class="nav-item nav-item-2"><a href="markup.html" accesskey="U">Structured Markup Processing Tools</a> &#187;</li>187        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code> — Support for SAX2 parsers</a></li>188                <li class="right">189                    190 191    <div class="inline-search" role="search">192        <form class="inline-search" action="../search.html" method="get">193          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">194          <input type="submit" value="Go">195        </form>196    </div>197                     |198                </li>199            <li class="right">200<label class="theme-selector-label">201    Theme202    <select class="theme-selector" oninput="activateTheme(this.value)">203        <option value="auto" selected>Auto</option>204        <option value="light">Light</option>205        <option value="dark">Dark</option>206    </select>207</label> |</li>208            209      </ul>210    </div>    211 212    <div class="document">213      <div class="documentwrapper">214        <div class="bodywrapper">215          <div class="body" role="main">216            217  <section id="module-xml.sax">218<span id="xml-sax-support-for-sax2-parsers"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code> — Support for SAX2 parsers<a class="headerlink" href="#module-xml.sax" title="Link to this heading">¶</a></h1>219<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/xml/sax/__init__.py">Lib/xml/sax/__init__.py</a></p>220<hr class="docutils" />221<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code> package provides a number of modules which implement the222Simple API for XML (SAX) interface for Python.  The package itself provides the223SAX exceptions and the convenience functions which will be most used by users of224the SAX API.</p>225<div class="admonition note">226<p class="admonition-title">Note</p>227<p>If you need to parse untrusted or unauthenticated data, see228<a class="reference internal" href="xml.html#xml-security"><span class="std std-ref">XML security</span></a>.</p>229</div>230<div class="versionchanged">231<p><span class="versionmodified changed">Changed in version 3.7.1: </span>The SAX parser no longer processes general external entities by default232to increase security. Before, the parser created network connections233to fetch remote files or loaded local files from the file234system for DTD and entities. The feature can be enabled again with method235<a class="reference internal" href="xml.sax.reader.html#xml.sax.xmlreader.XMLReader.setFeature" title="xml.sax.xmlreader.XMLReader.setFeature"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setFeature()</span></code></a> on the parser object236and argument <a class="reference internal" href="xml.sax.handler.html#xml.sax.handler.feature_external_ges" title="xml.sax.handler.feature_external_ges"><code class="xref py py-data docutils literal notranslate"><span class="pre">feature_external_ges</span></code></a>.</p>237</div>238<p>The convenience functions are:</p>239<dl class="py function">240<dt class="sig sig-object py" id="xml.sax.make_parser">241<span class="sig-prename descclassname"><span class="pre">xml.sax.</span></span><span class="sig-name descname"><span class="pre">make_parser</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parser_list</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">[]</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.make_parser" title="Link to this definition">¶</a></dt>242<dd><p>Create and return a SAX <a class="reference internal" href="xml.sax.reader.html#xml.sax.xmlreader.XMLReader" title="xml.sax.xmlreader.XMLReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">XMLReader</span></code></a> object.  The243first parser found will244be used.  If <em>parser_list</em> is provided, it must be an iterable of strings which245name modules that have a function named <code class="xref py py-func docutils literal notranslate"><span class="pre">create_parser()</span></code>.  Modules listed246in <em>parser_list</em> will be used before modules in the default list of parsers.</p>247<div class="versionchanged">248<p><span class="versionmodified changed">Changed in version 3.8: </span>The <em>parser_list</em> argument can be any iterable, not just a list.</p>249</div>250</dd></dl>251 252<dl class="py function">253<dt class="sig sig-object py" id="xml.sax.parse">254<span class="sig-prename descclassname"><span class="pre">xml.sax.</span></span><span class="sig-name descname"><span class="pre">parse</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename_or_stream</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">handler</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">error_handler</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">handler.ErrorHandler()</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.parse" title="Link to this definition">¶</a></dt>255<dd><p>Create a SAX parser and use it to parse a document.  The document, passed in as256<em>filename_or_stream</em>, can be a filename or a file object.  The <em>handler</em>257parameter needs to be a SAX <a class="reference internal" href="xml.sax.handler.html#xml.sax.handler.ContentHandler" title="xml.sax.handler.ContentHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">ContentHandler</span></code></a> instance.  If258<em>error_handler</em> is given, it must be a SAX <a class="reference internal" href="xml.sax.handler.html#xml.sax.handler.ErrorHandler" title="xml.sax.handler.ErrorHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">ErrorHandler</span></code></a>259instance; if260omitted,  <a class="reference internal" href="#xml.sax.SAXParseException" title="xml.sax.SAXParseException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SAXParseException</span></code></a> will be raised on all errors.  There is no261return value; all work must be done by the <em>handler</em> passed in.</p>262</dd></dl>263 264<dl class="py function">265<dt class="sig sig-object py" id="xml.sax.parseString">266<span class="sig-prename descclassname"><span class="pre">xml.sax.</span></span><span class="sig-name descname"><span class="pre">parseString</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">string</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">handler</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">error_handler</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">handler.ErrorHandler()</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.parseString" title="Link to this definition">¶</a></dt>267<dd><p>Similar to <a class="reference internal" href="#xml.sax.parse" title="xml.sax.parse"><code class="xref py py-func docutils literal notranslate"><span class="pre">parse()</span></code></a>, but parses from a buffer <em>string</em> received as a268parameter.  <em>string</em> must be a <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> instance or a269<a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a>.</p>270<div class="versionchanged">271<p><span class="versionmodified changed">Changed in version 3.5: </span>Added support of <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> instances.</p>272</div>273</dd></dl>274 275<p>A typical SAX application uses three kinds of objects: readers, handlers and276input sources.  “Reader” in this context is another term for parser, i.e. some277piece of code that reads the bytes or characters from the input source, and278produces a sequence of events. The events then get distributed to the handler279objects, i.e. the reader invokes a method on the handler.  A SAX application280must therefore obtain a reader object, create or open the input sources, create281the handlers, and connect these objects all together.  As the final step of282preparation, the reader is called to parse the input. During parsing, methods on283the handler objects are called based on structural and syntactic events from the284input data.</p>285<p>For these objects, only the interfaces are relevant; they are normally not286instantiated by the application itself.  Since Python does not have an explicit287notion of interface, they are formally introduced as classes, but applications288may use implementations which do not inherit from the provided classes.  The289<a class="reference internal" href="xml.sax.reader.html#xml.sax.xmlreader.InputSource" title="xml.sax.xmlreader.InputSource"><code class="xref py py-class docutils literal notranslate"><span class="pre">InputSource</span></code></a>, <a class="reference internal" href="xml.sax.reader.html#xml.sax.xmlreader.Locator" title="xml.sax.xmlreader.Locator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Locator</span></code></a>,290<code class="xref py py-class docutils literal notranslate"><span class="pre">Attributes</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">AttributesNS</span></code>,291and <a class="reference internal" href="xml.sax.reader.html#xml.sax.xmlreader.XMLReader" title="xml.sax.xmlreader.XMLReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">XMLReader</span></code></a> interfaces are defined in the292module <a class="reference internal" href="xml.sax.reader.html#module-xml.sax.xmlreader" title="xml.sax.xmlreader: Interface which SAX-compliant XML parsers must implement."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.xmlreader</span></code></a>.  The handler interfaces are defined in293<a class="reference internal" href="xml.sax.handler.html#module-xml.sax.handler" title="xml.sax.handler: Base classes for SAX event handlers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.handler</span></code></a>.  For convenience,294<code class="xref py py-class docutils literal notranslate"><span class="pre">InputSource</span></code> (which is often295instantiated directly) and the handler classes are also available from296<code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code>.  These interfaces are described below.</p>297<p>In addition to these classes, <code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code> provides the following exception298classes.</p>299<dl class="py exception">300<dt class="sig sig-object py" id="xml.sax.SAXException">301<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.sax.</span></span><span class="sig-name descname"><span class="pre">SAXException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exception</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.SAXException" title="Link to this definition">¶</a></dt>302<dd><p>Encapsulate an XML error or warning.  This class can contain basic error or303warning information from either the XML parser or the application: it can be304subclassed to provide additional functionality or to add localization.  Note305that although the handlers defined in the306<a class="reference internal" href="xml.sax.handler.html#xml.sax.handler.ErrorHandler" title="xml.sax.handler.ErrorHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">ErrorHandler</span></code></a> interface307receive instances of this exception, it is not required to actually raise the308exception — it is also useful as a container for information.</p>309<p>When instantiated, <em>msg</em> should be a human-readable description of the error.310The optional <em>exception</em> parameter, if given, should be <code class="docutils literal notranslate"><span class="pre">None</span></code> or an exception311that was caught by the parsing code and is being passed along as information.</p>312<p>This is the base class for the other SAX exception classes.</p>313</dd></dl>314 315<dl class="py exception">316<dt class="sig sig-object py" id="xml.sax.SAXParseException">317<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.sax.</span></span><span class="sig-name descname"><span class="pre">SAXParseException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exception</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">locator</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.SAXParseException" title="Link to this definition">¶</a></dt>318<dd><p>Subclass of <a class="reference internal" href="#xml.sax.SAXException" title="xml.sax.SAXException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SAXException</span></code></a> raised on parse errors. Instances of this319class are passed to the methods of the SAX320<a class="reference internal" href="xml.sax.handler.html#xml.sax.handler.ErrorHandler" title="xml.sax.handler.ErrorHandler"><code class="xref py py-class docutils literal notranslate"><span class="pre">ErrorHandler</span></code></a> interface to provide information321about the parse error.  This class supports the SAX322<a class="reference internal" href="xml.sax.reader.html#xml.sax.xmlreader.Locator" title="xml.sax.xmlreader.Locator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Locator</span></code></a> interface as well as the323<a class="reference internal" href="#xml.sax.SAXException" title="xml.sax.SAXException"><code class="xref py py-class docutils literal notranslate"><span class="pre">SAXException</span></code></a> interface.</p>324</dd></dl>325 326<dl class="py exception">327<dt class="sig sig-object py" id="xml.sax.SAXNotRecognizedException">328<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.sax.</span></span><span class="sig-name descname"><span class="pre">SAXNotRecognizedException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exception</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.SAXNotRecognizedException" title="Link to this definition">¶</a></dt>329<dd><p>Subclass of <a class="reference internal" href="#xml.sax.SAXException" title="xml.sax.SAXException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SAXException</span></code></a> raised when a SAX330<a class="reference internal" href="xml.sax.reader.html#xml.sax.xmlreader.XMLReader" title="xml.sax.xmlreader.XMLReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">XMLReader</span></code></a> is331confronted with an unrecognized feature or property.  SAX applications and332extensions may use this class for similar purposes.</p>333</dd></dl>334 335<dl class="py exception">336<dt class="sig sig-object py" id="xml.sax.SAXNotSupportedException">337<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">xml.sax.</span></span><span class="sig-name descname"><span class="pre">SAXNotSupportedException</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">exception</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.SAXNotSupportedException" title="Link to this definition">¶</a></dt>338<dd><p>Subclass of <a class="reference internal" href="#xml.sax.SAXException" title="xml.sax.SAXException"><code class="xref py py-exc docutils literal notranslate"><span class="pre">SAXException</span></code></a> raised when a SAX339<a class="reference internal" href="xml.sax.reader.html#xml.sax.xmlreader.XMLReader" title="xml.sax.xmlreader.XMLReader"><code class="xref py py-class docutils literal notranslate"><span class="pre">XMLReader</span></code></a> is asked to340enable a feature that is not supported, or to set a property to a value that the341implementation does not support.  SAX applications and extensions may use this342class for similar purposes.</p>343</dd></dl>344 345<div class="admonition seealso">346<p class="admonition-title">See also</p>347<dl class="simple">348<dt><a class="reference external" href="http://www.saxproject.org/">SAX: The Simple API for XML</a></dt><dd><p>This site is the focal point for the definition of the SAX API.  It provides a349Java implementation and online documentation.  Links to implementations and350historical information are also available.</p>351</dd>352<dt>Module <a class="reference internal" href="xml.sax.handler.html#module-xml.sax.handler" title="xml.sax.handler: Base classes for SAX event handlers."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.handler</span></code></a></dt><dd><p>Definitions of the interfaces for application-provided objects.</p>353</dd>354<dt>Module <a class="reference internal" href="xml.sax.utils.html#module-xml.sax.saxutils" title="xml.sax.saxutils: Convenience functions and classes for use with SAX."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.saxutils</span></code></a></dt><dd><p>Convenience functions for use in SAX applications.</p>355</dd>356<dt>Module <a class="reference internal" href="xml.sax.reader.html#module-xml.sax.xmlreader" title="xml.sax.xmlreader: Interface which SAX-compliant XML parsers must implement."><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.xmlreader</span></code></a></dt><dd><p>Definitions of the interfaces for parser-provided objects.</p>357</dd>358</dl>359</div>360<section id="saxexception-objects">361<span id="sax-exception-objects"></span><h2>SAXException Objects<a class="headerlink" href="#saxexception-objects" title="Link to this heading">¶</a></h2>362<p>The <a class="reference internal" href="#xml.sax.SAXException" title="xml.sax.SAXException"><code class="xref py py-class docutils literal notranslate"><span class="pre">SAXException</span></code></a> exception class supports the following methods:</p>363<dl class="py method">364<dt class="sig sig-object py" id="xml.sax.SAXException.getMessage">365<span class="sig-prename descclassname"><span class="pre">SAXException.</span></span><span class="sig-name descname"><span class="pre">getMessage</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.SAXException.getMessage" title="Link to this definition">¶</a></dt>366<dd><p>Return a human-readable message describing the error condition.</p>367</dd></dl>368 369<dl class="py method">370<dt class="sig sig-object py" id="xml.sax.SAXException.getException">371<span class="sig-prename descclassname"><span class="pre">SAXException.</span></span><span class="sig-name descname"><span class="pre">getException</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#xml.sax.SAXException.getException" title="Link to this definition">¶</a></dt>372<dd><p>Return an encapsulated exception object, or <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>373</dd></dl>374 375</section>376</section>377 378 379            <div class="clearer"></div>380          </div>381        </div>382      </div>383      <div class="sphinxsidebar" role="navigation" aria-label="Main">384        <div class="sphinxsidebarwrapper">385  <div>386    <h3><a href="../contents.html">Table of Contents</a></h3>387    <ul>388<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code> — Support for SAX2 parsers</a><ul>389<li><a class="reference internal" href="#saxexception-objects">SAXException Objects</a></li>390</ul>391</li>392</ul>393 394  </div>395  <div>396    <h4>Previous topic</h4>397    <p class="topless"><a href="xml.dom.pulldom.html"398                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.dom.pulldom</span></code> — Support for building partial DOM trees</a></p>399  </div>400  <div>401    <h4>Next topic</h4>402    <p class="topless"><a href="xml.sax.handler.html"403                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax.handler</span></code> — Base classes for SAX handlers</a></p>404  </div>405  <script>406    document.addEventListener('DOMContentLoaded', () => {407        const title = document.querySelector('meta[property="og:title"]').content;408        const elements = document.querySelectorAll('.improvepage');409        const pageurl = window.location.href.split('?')[0];410        elements.forEach(element => {411            const url = new URL(element.href.split('?')[0].replace("-nojs", ""));412            url.searchParams.set('pagetitle', title);413            url.searchParams.set('pageurl', pageurl);414            url.searchParams.set('pagesource', "library/xml.sax.rst");415            element.href = url.toString();416        });417    });418  </script>419  <div role="note" aria-label="source link">420    <h3>This page</h3>421    <ul class="this-page-menu">422      <li><a href="../bugs.html">Report a bug</a></li>423      <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>424      <li>425        <a href="https://github.com/python/cpython/blob/main/Doc/library/xml.sax.rst?plain=1"426            rel="nofollow">Show source427        </a>428      </li>429      430    </ul>431  </div>432        </div>433<div id="sidebarbutton" title="Collapse sidebar">434<span>«</span>435</div>436 437      </div>438      <div class="clearer"></div>439    </div>  440    <div class="related" role="navigation" aria-label="Related">441      <h3>Navigation</h3>442      <ul>443        <li class="right" style="margin-right: 10px">444          <a href="../genindex.html" title="General Index"445             >index</a></li>446        <li class="right" >447          <a href="../py-modindex.html" title="Python Module Index"448             >modules</a> |</li>449        <li class="right" >450          <a href="xml.sax.handler.html" title="xml.sax.handler — Base classes for SAX handlers"451             >next</a> |</li>452        <li class="right" >453          <a href="xml.dom.pulldom.html" title="xml.dom.pulldom — Support for building partial DOM trees"454             >previous</a> |</li>455 456          <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>457          <li><a href="https://www.python.org/">Python</a> &#187;</li>458          <li class="switchers">459            <div class="language_switcher_placeholder"></div>460            <div class="version_switcher_placeholder"></div>461          </li>462          <li>463              464          </li>465    <li id="cpython-language-and-version">466      <a href="../index.html">3.15.0a6 Documentation</a> &#187;467    </li>468 469          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>470          <li class="nav-item nav-item-2"><a href="markup.html" >Structured Markup Processing Tools</a> &#187;</li>471        <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">xml.sax</span></code> — Support for SAX2 parsers</a></li>472                <li class="right">473                    474 475    <div class="inline-search" role="search">476        <form class="inline-search" action="../search.html" method="get">477          <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">478          <input type="submit" value="Go">479        </form>480    </div>481                     |482                </li>483            <li class="right">484<label class="theme-selector-label">485    Theme486    <select class="theme-selector" oninput="activateTheme(this.value)">487        <option value="auto" selected>Auto</option>488        <option value="light">Light</option>489        <option value="dark">Dark</option>490    </select>491</label> |</li>492            493      </ul>494    </div>  495    <div class="footer">496    &copy; <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.497    <br>498    This page is licensed under the Python Software Foundation License Version 2.499    <br>500    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.501    <br>502    503      See <a href="/license.html">History and License</a> for more information.<br>504    505    506    <br>507 508    The Python Software Foundation is a non-profit corporation.509<a href="https://www.python.org/psf/donations/">Please donate.</a>510<br>511    <br>512      Last updated on Mar 10, 2026 (08:58 UTC).513    514      <a href="/bugs.html">Found a bug</a>?515    516    <br>517 518    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.519    </div>520 521  </body>522</html>