View Full Version : QXmlQuery not transforming XSL

18th June 2009, 07:47
Hello all,

I am reasonably new to Python/QT and am having a few issues with transforming an XML file into HTML to be displayed in a QWebView by using an xsl file.

I am using QXmlQuery to take in the XML and XSL files but the problem I seem to be having is that it doesn't appear to produce a result when using .evaluateTo(). My peference is to pass through a generated XML string to the .setFocus() and then retrieve a string containing the HTML from the .evelauteTo(). But for testing I am just passing the XML file through from the file system.

I have attached my python/QT code as well as the XML/XSL doucments that may assist.

PyQT code:

dummyString = QString()

xmlQuery = QXmlQuery(QXmlQuery.XSLT20)

print dummyString (nothing returned)


<?xml version="1.0" encoding="ISO-8859-1"?>
<SurveyName>North West Western Australia</SurveyName>
<Lease>North West Shelf</Lease>
<ClientName>Client 1</ClientName>
<MMOProviderName>MMO provider 1</MMOProviderName>
<SeismicContractorName>Seismic contractor 1</SeismicContractorName>


<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="data">
<table border="1">
<tr bgcolor="#343434">
<xsl:for-each select="Survey_Data/Survey">
<td><xsl:value-of select="SurveyId"/></td>
<td><xsl:value-of select="ClientName"/></td>

Thank you.


24th June 2009, 01:26
Still no luck, can any one shed some light on what I may be doing wrong?

24th June 2009, 01:46
What is the output you receive? Did you make sure the data is loaded correctly?

24th June 2009, 07:03
There is no output at all, also no errors when opening the files from the file system.

How would you suggest debugging the QXmlQuery object to test to see if it is reading the XML and XSL files correctly?

Thank you for your response and assistance.

24th June 2009, 10:26
I would start by using QUrl::fromLocalFile()to make sure the URLs are correct and before that I would use QFile::exists() to see if the relative paths are correct.