コード例 #1
0
ファイル: Sax2.py プロジェクト: OYZQ/odoo_qingjia
 def __init__(self,
              validate=0,
              keepAllWs=0,
              catName=None,
              saxHandlerClass=XmlDomGenerator,
              parser=None):
     self.parser = parser or (validate and
                              sax2exts.XMLValParserFactory.make_parser()
                              ) or sax2exts.XMLParserFactory.make_parser()
     if catName:
         #set up the catalog, if there is one
         from xml.parsers.xmlproc import catalog
         cat_handler = catalog.SAX_catalog(catName,
                                           catalog.CatParserFactory())
         self.parser.setEntityResolver(cat_handler)
     self.handler = saxHandlerClass(keepAllWs)
     self.parser.setContentHandler(self.handler)
     self.parser.setDTDHandler(self.handler)
     self.parser.setErrorHandler(self.handler)
     try:
         #FIXME: Maybe raise a warning?
         self.parser.setProperty(handler.property_lexical_handler,
                                 self.handler)
         self.parser.setProperty(handler.property_declaration_handler,
                                 self.handler)
     except (SystemExit, KeyboardInterrupt):
         raise
     except:
         pass
     return
コード例 #2
0
ファイル: Sax.py プロジェクト: AhmedSeyam2020/HBL
 def __init__(self, validate=0, keepAllWs=0, catName=None,
              saxHandlerClass=XmlDomGenerator, parser=None):
     #Create an XML DOM from SAX events
     self.parser = parser or (validate and saxexts.XMLValParserFactory.make_parser()) or saxexts.XMLParserFactory.make_parser()
     if catName:
         #set up the catalog, if there is one
         from xml.parsers.xmlproc import catalog
         cat_handler = catalog.SAX_catalog(catName, catalog.CatParserFactory())
         self.parser.setEntityResolver(cat_handler)
     self.handler = saxHandlerClass(keepAllWs)
     self.parser.setDocumentHandler(self.handler)
     self.parser.setDTDHandler(self.handler)
     self.parser.setErrorHandler(self.handler)
     return