I like to display some (X)HTML content in a Qt application using QtWebKit. The content should be generated from XML documents via XSLT.
As I am new to Qt, my questions are as follows:
1) Can QtWebKit display XML documents with the xml-stylesheet element set?
2) Can Qt apply XSLT to an XML document and return the result as a string or write it to a file?
With QXmlQuery
you can process a XML document against a XSL template and then pass the result to the 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 more information in the QXmlQuery documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With