Inherits xml::sax::handler::ContentHandler.
Inherited by rpki.left_right.sax_handler, rpki.publication.sax_handler, and rpki.up_down.sax_handler.
Public Member Functions | |
def | __init__ |
def | characters |
def | create_top_level |
def | endElement |
def | endElementNS |
def | saxify |
def | startElement |
def | startElementNS |
Public Attributes | |
result | |
stack | |
text |
SAX handler for RPKI protocols. This class provides some basic amenities for parsing protocol XML of the kind we use in the RPKI protocols, including whacking all the protocol element text into US-ASCII, simplifying accumulation of text fields, and hiding some of the fun relating to XML namespaces. General assumption: by the time this parsing code gets invoked, the XML has already passed RelaxNG validation, so we only have to check for errors that the schema can't catch, and we don't have to play as many XML namespace games.
Definition at line 38 of file xml_utils.py.
def rpki.xml_utils.sax_handler.__init__ | ( | self | ) |
Initialize SAX handler.
Definition at line 53 of file xml_utils.py.
def rpki.xml_utils.sax_handler.characters | ( | self, | ||
content | ||||
) |
Accumulate a chuck of element content (text).
Definition at line 69 of file xml_utils.py.
def rpki.xml_utils.sax_handler.create_top_level | ( | self, | ||
name, | ||||
attrs | ||||
) |
Handle top-level PDU for this protocol.
Definition at line 119 of file xml_utils.py.
def rpki.xml_utils.sax_handler.endElement | ( | self, | ||
name | ||||
) |
Handle endElement() events. Mostly this means handling any accumulated element text.
Definition at line 101 of file xml_utils.py.
def rpki.xml_utils.sax_handler.endElementNS | ( | self, | ||
name, | ||||
qname | ||||
) |
Redirect endElementNS() events to endElement().
Definition at line 65 of file xml_utils.py.
def rpki.xml_utils.sax_handler.saxify | ( | cls, | ||
elt | ||||
) |
Create a one-off SAX parser, parse an ETree, return the result.
Definition at line 111 of file xml_utils.py.
def rpki.xml_utils.sax_handler.startElement | ( | self, | ||
name, | ||||
attrs | ||||
) |
Handle startElement() events. We maintain a stack of nested elements under construction so that we can feed events directly to the current element rather than having to pass them through all the nesting elements. If the stack is empty, this event is for the outermost element, so we call a virtual method to create the corresponding object and that's the object we'll be returning as our final result.
Definition at line 73 of file xml_utils.py.
def rpki.xml_utils.sax_handler.startElementNS | ( | self, | ||
name, | ||||
qname, | ||||
attrs | ||||
) |
Redirect startElementNS() events to startElement().
Definition at line 61 of file xml_utils.py.
Definition at line 97 of file xml_utils.py.
Definition at line 59 of file xml_utils.py.
Definition at line 58 of file xml_utils.py.