Back to index

python3.2  3.2.2
Public Member Functions | Private Attributes
xml.sax.handler.ContentHandler Class Reference
Inheritance diagram for xml.sax.handler.ContentHandler:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def __init__
def setDocumentLocator
def startDocument
def endDocument
def startPrefixMapping
def endPrefixMapping
def startElement
def endElement
def startElementNS
def endElementNS
def characters
def ignorableWhitespace
def processingInstruction
def skippedEntity

Private Attributes

 _locator

Detailed Description

Interface for receiving logical document content events.

This is the main callback interface in SAX, and the one most
important to applications. The order of events in this interface
mirrors the order of the information in the document.

Definition at line 47 of file handler.py.


Constructor & Destructor Documentation

Definition at line 54 of file handler.py.

00054 
00055     def __init__(self):
00056         self._locator = None

Here is the caller graph for this function:


Member Function Documentation

def xml.sax.handler.ContentHandler.characters (   self,
  content 
)
Receive notification of character data.

The Parser will call this method to report each chunk of
character data. SAX parsers may return all contiguous
character data in a single chunk, or they may split it into
several chunks; however, all of the characters in any single
event must come from the same external entity so that the
Locator provides useful information.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 158 of file handler.py.

00158 
00159     def characters(self, content):
00160         """Receive notification of character data.
00161 
00162         The Parser will call this method to report each chunk of
00163         character data. SAX parsers may return all contiguous
00164         character data in a single chunk, or they may split it into
00165         several chunks; however, all of the characters in any single
00166         event must come from the same external entity so that the
00167         Locator provides useful information."""

Receive notification of the end of a document.

The SAX parser will invoke this method only once, and it will
be the last method invoked during the parse. The parser shall
not invoke this method until it has either abandoned parsing
(because of an unrecoverable error) or reached the end of
input.

Definition at line 87 of file handler.py.

00087 
00088     def endDocument(self):
00089         """Receive notification of the end of a document.
00090 
00091         The SAX parser will invoke this method only once, and it will
00092         be the last method invoked during the parse. The parser shall
00093         not invoke this method until it has either abandoned parsing
00094         (because of an unrecoverable error) or reached the end of
00095         input."""

def xml.sax.handler.ContentHandler.endElement (   self,
  name 
)
Signals the end of an element in non-namespace mode.

The name parameter contains the name of the element type, just
as with the startElement event.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 134 of file handler.py.

00134 
00135     def endElement(self, name):
00136         """Signals the end of an element in non-namespace mode.
00137 
00138         The name parameter contains the name of the element type, just
00139         as with the startElement event."""

def xml.sax.handler.ContentHandler.endElementNS (   self,
  name,
  qname 
)
Signals the end of an element in namespace mode.

The name parameter contains the name of the element type, just
as with the startElementNS event.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 152 of file handler.py.

00152 
00153     def endElementNS(self, name, qname):
00154         """Signals the end of an element in namespace mode.
00155 
00156         The name parameter contains the name of the element type, just
00157         as with the startElementNS event."""

End the scope of a prefix-URI mapping.

See startPrefixMapping for details. This event will always
occur after the corresponding endElement event, but the order
of endPrefixMapping events is not otherwise guaranteed.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 119 of file handler.py.

00119 
00120     def endPrefixMapping(self, prefix):
00121         """End the scope of a prefix-URI mapping.
00122 
00123         See startPrefixMapping for details. This event will always
00124         occur after the corresponding endElement event, but the order
00125         of endPrefixMapping events is not otherwise guaranteed."""

def xml.sax.handler.ContentHandler.ignorableWhitespace (   self,
  whitespace 
)
Receive notification of ignorable whitespace in element content.

Validating Parsers must use this method to report each chunk
of ignorable whitespace (see the W3C XML 1.0 recommendation,
section 2.10): non-validating parsers may also use this method
if they are capable of parsing and using content models.

SAX parsers may return all contiguous whitespace in a single
chunk, or they may split it into several chunks; however, all
of the characters in any single event must come from the same
external entity, so that the Locator provides useful
information.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 168 of file handler.py.

00168 
00169     def ignorableWhitespace(self, whitespace):
00170         """Receive notification of ignorable whitespace in element content.
00171 
00172         Validating Parsers must use this method to report each chunk
00173         of ignorable whitespace (see the W3C XML 1.0 recommendation,
00174         section 2.10): non-validating parsers may also use this method
00175         if they are capable of parsing and using content models.
00176 
00177         SAX parsers may return all contiguous whitespace in a single
00178         chunk, or they may split it into several chunks; however, all
00179         of the characters in any single event must come from the same
00180         external entity, so that the Locator provides useful
00181         information."""

def xml.sax.handler.ContentHandler.processingInstruction (   self,
  target,
  data 
)
Receive notification of a processing instruction.

The Parser will invoke this method once for each processing
instruction found: note that processing instructions may occur
before or after the main document element.

A SAX parser should never report an XML declaration (XML 1.0,
section 2.8) or a text declaration (XML 1.0, section 4.3.1)
using this method.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 182 of file handler.py.

00182 
00183     def processingInstruction(self, target, data):
00184         """Receive notification of a processing instruction.
00185 
00186         The Parser will invoke this method once for each processing
00187         instruction found: note that processing instructions may occur
00188         before or after the main document element.
00189 
00190         A SAX parser should never report an XML declaration (XML 1.0,
00191         section 2.8) or a text declaration (XML 1.0, section 4.3.1)
00192         using this method."""

Called by the parser to give the application a locator for
locating the origin of document events.

SAX parsers are strongly encouraged (though not absolutely
required) to supply a locator: if it does so, it must supply
the locator to the application by invoking this method before
invoking any of the other methods in the DocumentHandler
interface.

The locator allows the application to determine the end
position of any document-related event, even if the parser is
not reporting an error. Typically, the application will use
this information for reporting its own errors (such as
character content that does not match an application's
business rules). The information returned by the locator is
probably not sufficient for use with a search engine.

Note that the locator will return correct information only
during the invocation of the events in this interface. The
application should not attempt to use it at any other time.

Definition at line 57 of file handler.py.

00057 
00058     def setDocumentLocator(self, locator):
00059         """Called by the parser to give the application a locator for
00060         locating the origin of document events.
00061 
00062         SAX parsers are strongly encouraged (though not absolutely
00063         required) to supply a locator: if it does so, it must supply
00064         the locator to the application by invoking this method before
00065         invoking any of the other methods in the DocumentHandler
00066         interface.
00067 
00068         The locator allows the application to determine the end
00069         position of any document-related event, even if the parser is
00070         not reporting an error. Typically, the application will use
00071         this information for reporting its own errors (such as
00072         character content that does not match an application's
00073         business rules). The information returned by the locator is
00074         probably not sufficient for use with a search engine.
00075 
00076         Note that the locator will return correct information only
00077         during the invocation of the events in this interface. The
00078         application should not attempt to use it at any other time."""
00079         self._locator = locator

Receive notification of a skipped entity.

The Parser will invoke this method once for each entity
skipped. Non-validating processors may skip entities if they
have not seen the declarations (because, for example, the
entity was declared in an external DTD subset). All processors
may skip external entities, depending on the values of the
http://xml.org/sax/features/external-general-entities and the
http://xml.org/sax/features/external-parameter-entities
properties.

Definition at line 193 of file handler.py.

00193 
00194     def skippedEntity(self, name):
00195         """Receive notification of a skipped entity.
00196 
00197         The Parser will invoke this method once for each entity
00198         skipped. Non-validating processors may skip entities if they
00199         have not seen the declarations (because, for example, the
00200         entity was declared in an external DTD subset). All processors
00201         may skip external entities, depending on the values of the
00202         http://xml.org/sax/features/external-general-entities and the
00203         http://xml.org/sax/features/external-parameter-entities
00204         properties."""
00205 
00206 
00207 # ===== DTDHandler =====

Receive notification of the beginning of a document.

The SAX parser will invoke this method only once, before any
other methods in this interface or in DTDHandler (except for
setDocumentLocator).

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 80 of file handler.py.

00080 
00081     def startDocument(self):
00082         """Receive notification of the beginning of a document.
00083 
00084         The SAX parser will invoke this method only once, before any
00085         other methods in this interface or in DTDHandler (except for
00086         setDocumentLocator)."""

def xml.sax.handler.ContentHandler.startElement (   self,
  name,
  attrs 
)
Signals the start of an element in non-namespace mode.

The name parameter contains the raw XML 1.0 name of the
element type as a string and the attrs parameter holds an
instance of the Attributes class containing the attributes of
the element.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 126 of file handler.py.

00126 
00127     def startElement(self, name, attrs):
00128         """Signals the start of an element in non-namespace mode.
00129 
00130         The name parameter contains the raw XML 1.0 name of the
00131         element type as a string and the attrs parameter holds an
00132         instance of the Attributes class containing the attributes of
00133         the element."""

def xml.sax.handler.ContentHandler.startElementNS (   self,
  name,
  qname,
  attrs 
)
Signals the start of an element in namespace mode.

The name parameter contains the name of the element type as a
(uri, localname) tuple, the qname parameter the raw XML 1.0
name used in the source document, and the attrs parameter
holds an instance of the Attributes class containing the
attributes of the element.

The uri part of the name tuple is None for elements which have
no namespace.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 140 of file handler.py.

00140 
00141     def startElementNS(self, name, qname, attrs):
00142         """Signals the start of an element in namespace mode.
00143 
00144         The name parameter contains the name of the element type as a
00145         (uri, localname) tuple, the qname parameter the raw XML 1.0
00146         name used in the source document, and the attrs parameter
00147         holds an instance of the Attributes class containing the
00148         attributes of the element.
00149 
00150         The uri part of the name tuple is None for elements which have
00151         no namespace."""

def xml.sax.handler.ContentHandler.startPrefixMapping (   self,
  prefix,
  uri 
)
Begin the scope of a prefix-URI Namespace mapping.

The information from this event is not necessary for normal
Namespace processing: the SAX XML reader will automatically
replace prefixes for element and attribute names when the
http://xml.org/sax/features/namespaces feature is true (the
default).

There are cases, however, when applications need to use
prefixes in character data or in attribute values, where they
cannot safely be expanded automatically; the
start/endPrefixMapping event supplies the information to the
application to expand prefixes in those contexts itself, if
necessary.

Note that start/endPrefixMapping events are not guaranteed to
be properly nested relative to each-other: all
startPrefixMapping events will occur before the corresponding
startElement event, and all endPrefixMapping events will occur
after the corresponding endElement event, but their order is
not guaranteed.

Reimplemented in xml.sax.saxutils.XMLGenerator.

Definition at line 96 of file handler.py.

00096 
00097     def startPrefixMapping(self, prefix, uri):
00098         """Begin the scope of a prefix-URI Namespace mapping.
00099 
00100         The information from this event is not necessary for normal
00101         Namespace processing: the SAX XML reader will automatically
00102         replace prefixes for element and attribute names when the
00103         http://xml.org/sax/features/namespaces feature is true (the
00104         default).
00105 
00106         There are cases, however, when applications need to use
00107         prefixes in character data or in attribute values, where they
00108         cannot safely be expanded automatically; the
00109         start/endPrefixMapping event supplies the information to the
00110         application to expand prefixes in those contexts itself, if
00111         necessary.
00112 
00113         Note that start/endPrefixMapping events are not guaranteed to
00114         be properly nested relative to each-other: all
00115         startPrefixMapping events will occur before the corresponding
00116         startElement event, and all endPrefixMapping events will occur
00117         after the corresponding endElement event, but their order is
00118         not guaranteed."""


Member Data Documentation

Called by the parser to give the application a locator for
locating the origin of document events.

SAX parsers are strongly encouraged (though not absolutely
required) to supply a locator: if it does so, it must supply
the locator to the application by invoking this method before
invoking any of the other methods in the DocumentHandler
interface.

The locator allows the application to determine the end
position of any document-related event, even if the parser is
not reporting an error. Typically, the application will use
this information for reporting its own errors (such as
character content that does not match an application's
business rules). The information returned by the locator is
probably not sufficient for use with a search engine.

Note that the locator will return correct information only
during the invocation of the events in this interface. The
application should not attempt to use it at any other time.

Definition at line 55 of file handler.py.


The documentation for this class was generated from the following file: