def Parse(self, *args): sysid = string.strip(self.loc.GetValue()) if sysid == "": self.SetStatusText("Nothing to parse") return self.parser.reset() self.errors.reset() self.errors.show_warnings = self.warn.GetValue() if self.cat.GetValue != "": self.SetStatusText("Parsing catalog...") pf = xcatalog.FancyParserFactory() cat = catalog.xmlproc_catalog(self.cat.GetValue(), pf, self.errors) self.parser.set_pubid_resolver(cat) self.SetStatusText("Parsing...") if self.output.GetValue(): output = cStringIO.StringIO() self.parser.set_application(utils.DocGenerator(output)) self.parser.set_error_handler(self.errors) self.parser.set_error_language(self.lang.GetValue()) self.parser.parse_resource(sysid) self.list.DeleteAllItems() ix = 0 for (sysid, line, col, msg) in self.errors.errors: self.list.InsertStringItem(ix, sysid) self.list.SetStringItem(ix, 1, ` line `) self.list.SetStringItem(ix, 2, ` col `) self.list.SetStringItem(ix, 3, msg) ix = ix + 1 self.list.SetColumnWidth(0, wxLIST_AUTOSIZE) self.list.SetColumnWidth(1, wxLIST_AUTOSIZE) self.list.SetColumnWidth(2, wxLIST_AUTOSIZE) self.list.SetColumnWidth(3, wxLIST_AUTOSIZE) if self.output.GetValue(): self.CreateOutputWindow(output) self.SetStatusText("Parse completed (%s error(s))" % ix)
def Parse(self, *args): sysid = string.strip(self.loc.GetValue()) if sysid == "": self.SetStatusText("Nothing to parse") return self.parser.reset() self.errors.reset() self.errors.show_warnings = self.warn.GetValue() if self.cat.GetValue != "": self.SetStatusText("Parsing catalog...") pf=xcatalog.FancyParserFactory() cat=catalog.xmlproc_catalog(self.cat.GetValue(),pf,self.errors) self.parser.set_pubid_resolver(cat) self.SetStatusText("Parsing...") if self.output.GetValue(): output = cStringIO.StringIO() self.parser.set_application(utils.DocGenerator(output)) self.parser.set_error_handler(self.errors) self.parser.set_error_language(self.lang.GetValue()) self.parser.parse_resource(sysid) self.list.DeleteAllItems() ix=0 for (sysid,line,col,msg) in self.errors.errors: self.list.InsertStringItem(ix, sysid) self.list.SetStringItem(ix, 1, `line`) self.list.SetStringItem(ix, 2, `col`) self.list.SetStringItem(ix, 3, msg) ix=ix+1 self.list.SetColumnWidth(0, wxLIST_AUTOSIZE) self.list.SetColumnWidth(1, wxLIST_AUTOSIZE) self.list.SetColumnWidth(2, wxLIST_AUTOSIZE) self.list.SetColumnWidth(3, wxLIST_AUTOSIZE) if self.output.GetValue(): self.CreateOutputWindow(output) self.SetStatusText("Parse completed (%s error(s))" % ix)
p.set_application(nsf) else: p.set_application(app) if cat != None: pf = xcatalog.FancyParserFactory(err_lang) elif cat == None and os.environ.has_key("XMLXCATALOG"): cat = os.environ["XMLXCATALOG"] pf = xcatalog.XCatParserFactory(err_lang) elif cat == None and os.environ.has_key("XMLSOCATALOG"): cat = os.environ["XMLSOCATALOG"] pf = catalog.CatParserFactory(err_lang) if cat != None: print "Parsing catalog file '%s'" % cat cat = catalog.xmlproc_catalog(cat, pf, err) p.set_pubid_resolver(cat) if len(sysids) == 0: if cat == None: print_usage("You must specify a system identifier if no catalog is " "used") elif cat.get_document_sysid() == None: print_usage("You must specify a system identifier if the catalog has " "no DOCUMENT entry") sysids = [cat.get_document_sysid()] print "Parsing DOCUMENT '%s' from catalog" % sysids[0] # --- Parsing
p.set_application(nsf) else: p.set_application(app) if cat!=None: pf=xcatalog.FancyParserFactory(err_lang) elif cat==None and os.environ.has_key("XMLXCATALOG"): cat=os.environ["XMLXCATALOG"] pf=xcatalog.XCatParserFactory(err_lang) elif cat==None and os.environ.has_key("XMLSOCATALOG"): cat=os.environ["XMLSOCATALOG"] pf=catalog.CatParserFactory(err_lang) if cat!=None: print "Parsing catalog file '%s'" % cat cat=catalog.xmlproc_catalog(cat,pf,err) p.set_pubid_resolver(cat) if len(sysids)==0: if cat==None: print_usage("You must specify a system identifier if no catalog is " "used") elif cat.get_document_sysid()==None: print_usage("You must specify a system identifier if the catalog has " "no DOCUMENT entry") sysids=[cat.get_document_sysid()] print "Parsing DOCUMENT '%s' from catalog" % sysids[0] # --- Parsing