Handling XSLT with Qt

I like to display some (X) HTML content in a Qt application using QtWebKit. Content must be created from XML documents through XSLT.

Since I'm new to Qt, my questions are as follows:
1) Can QtWebKit display XML documents using a set of xml-stylesheet elements?
2) Can Qt apply XSLT to an XML document and return the result as a string or write it to a file?

+4
source share
2 answers

QtWebKit and xslt have always been separate, combining them has always been todo - not sure what the current status is, but you can easily check it with examples.

Or follow http://labs.trolltech.com/blogs/2010/03/03/qtwebkit-releases/

0
source

With QXmlQuery you can process the XML document against the XSL template and then pass the result to QWebView::setHtml(QString) (recent versions of Qt will use QWebEngineView::setHtml(..) .

 QString out; QXmlQuery query(QXmlQuery::XSLT20); query.setFocus(QUrl("myInput.xml")); query.setQuery(QUrl("myStylesheet.xsl")); query.evaluateTo(&out); webview->setHtml(out); 

You can find this code and additional information in the QXmlQuery documentation .

+10
source

Source: https://habr.com/ru/post/1303938/


All Articles