def compute(self): """ compute() -> None Render the XML tree and display it on the spreadsheet """ xml = self.getInputFromPort('XML').name xsl = self.getInputFromPort('XSL').name query = QXmlQuery(QXmlQuery.XSLT20) query.setFocus(QUrl.fromLocalFile(os.path.join(os.getcwd(), xml))) query.setQuery(QUrl.fromLocalFile(os.path.join(os.getcwd(), xsl))) html = query.evaluateToString() self.cellWidget = self.displayAndWait(RichTextCellWidget, (html,))
def getHtml(self, md): xsltFile = QFile(self.xsltFilePath) xsltFile.open(QIODevice.ReadOnly) xslt = unicode(xsltFile.readAll()) xsltFile.close() qry = QXmlQuery(QXmlQuery.XSLT20) '''self.handler = ErrorHandler() qry.setMessageHandler(self.handler)''' qry.setFocus(md) qry.setQuery(xslt) return qry.evaluateToString()
class QueryDisplay(QObject): def __init__(self, datapath, querypath): super(QueryDisplay,self).__init__() self.datapath = datapath self.querypath = querypath self.view = QWebView() self.queryimpl = QXmlQuery(QXmlQuery.XQuery10) @pyqtSlot() def update(self, watchdog_event=None): self.queryimpl.setFocus(QUrl.fromLocalFile(self.datapath)) self.queryimpl.setQuery(QUrl.fromLocalFile(self.querypath)) self.view.setHtml(self.queryimpl.evaluateToString())
def errorHandler(self, resultXML): if resultXML: qDebug(resultXML) query = QXmlQuery(QXmlQuery.XSLT20) xslFile = QFile(":/plugins/wps/exception.xsl") xslFile.open(QIODevice.ReadOnly) bRead = query.setFocus(resultXML) query.setQuery(xslFile) exceptionHtml = query.evaluateToString() if exceptionHtml is None: qDebug("Empty result from exception.xsl") exceptionHtml = resultXML self._errorResultCallback(exceptionHtml) xslFile.close() return False
def compute(self): """ compute() -> None Render the XML tree and display it on the spreadsheet """ xml = self.get_input('XML').name xsl = self.get_input('XSL').name query = QXmlQuery(QXmlQuery.XSLT20) query.setFocus(QUrl.fromLocalFile(os.path.join(os.getcwd(), xml))) query.setQuery(QUrl.fromLocalFile(os.path.join(os.getcwd(), xsl))) html = query.evaluateToString() # gets a unicode object if html is None: raise ModuleError(self, "Error applying XSL") self.displayAndWait(RichTextCellWidget, (html,))
def compute(self): """ compute() -> None Render the XML tree and display it on the spreadsheet """ xml = self.get_input('XML').name xsl = self.get_input('XSL').name query = QXmlQuery(QXmlQuery.XSLT20) query.setFocus(QUrl.fromLocalFile(os.path.join(os.getcwd(), xml))) query.setQuery(QUrl.fromLocalFile(os.path.join(os.getcwd(), xsl))) html = query.evaluateToString() # gets a unicode object if html is None: raise ModuleError(self, "Error applying XSL") self.displayAndWait(RichTextCellWidget, (html, ))
def save(self, serialized, filepath=None): if filepath == None: if self.loadedpath == None: raise Error("Cannot guess filepath, no onload event was triggered") else: filepath = self.loadedpath f = open(filepath, 'w') savefilter = QXmlQuery(QXmlQuery.XQuery10) savefilter.setFocus(serialized) savefilter.setQuery(QUrl(os.path.realpath(self.savefilterpath))) result = savefilter.evaluateToString() result = result.toUtf8() f.write(result) f.close() return filepath