Install the callbacks needed to build the DOM into the parser.
(self, parser)
| 172 | self._cdata = False |
| 173 | |
| 174 | def install(self, parser): |
| 175 | """Install the callbacks needed to build the DOM into the parser.""" |
| 176 | # This creates circular references! |
| 177 | parser.StartDoctypeDeclHandler = self.start_doctype_decl_handler |
| 178 | parser.StartElementHandler = self.first_element_handler |
| 179 | parser.EndElementHandler = self.end_element_handler |
| 180 | parser.ProcessingInstructionHandler = self.pi_handler |
| 181 | if self._options.entities: |
| 182 | parser.EntityDeclHandler = self.entity_decl_handler |
| 183 | parser.NotationDeclHandler = self.notation_decl_handler |
| 184 | if self._options.comments: |
| 185 | parser.CommentHandler = self.comment_handler |
| 186 | if self._options.cdata_sections: |
| 187 | parser.StartCdataSectionHandler = self.start_cdata_section_handler |
| 188 | parser.EndCdataSectionHandler = self.end_cdata_section_handler |
| 189 | parser.CharacterDataHandler = self.character_data_handler_cdata |
| 190 | else: |
| 191 | parser.CharacterDataHandler = self.character_data_handler |
| 192 | parser.ExternalEntityRefHandler = self.external_entity_ref_handler |
| 193 | parser.XmlDeclHandler = self.xml_decl_handler |
| 194 | parser.ElementDeclHandler = self.element_decl_handler |
| 195 | parser.AttlistDeclHandler = self.attlist_decl_handler |
| 196 | |
| 197 | def parseFile(self, file): |
| 198 | """Parse a document from a file object, returning the document |