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:
Qt Code:
  1. dummyString = QString()
  2.  
  3. xmlQuery = QXmlQuery(QXmlQuery.XSLT20)
  4. xmlQuery.setFocus(QUrl('../DATA/test.xml'))
  5. xmlQuery.setQuery(QUrl('../DATA/test.xsl'))
  6. xmlQuery.evaluateTo(dummyString)
  7.  
  8. print dummyString (nothing returned)
To copy to clipboard, switch view to plain text mode 

XML:
Qt Code:
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <Data>
  3. <Survey_Data>
  4. <Survey>
  5. <SurveyId>1</SurveyId>
  6. <ClientId>1</ClientId>
  7. <MMOProviderId>1</MMOProviderId>
  8. <SeismicContractorId>1</SeismicContractorId>
  9. <SurveyName>North West Western Australia</SurveyName>
  10. <Lease>North West Shelf</Lease>
  11. <DEWHAReferralReferenceNumber></DEWHAReferralReferenceNumber>
  12. <StartDate>2008-01-01</StartDate>
  13. <EndDate>2008-01-19</EndDate>
  14. <SourceFullPowerDuration></SourceFullPowerDuration>
  15. <SourcePowerDownDistance></SourcePowerDownDistance>
  16. <ShutDownDistance></ShutDownDistance>
  17. <SourceVolume></SourceVolume>
  18. <AirgunNumber></AirgunNumber>
  19. <SPIntervalMetres></SPIntervalMetres>
  20. <SPIntervalSeconds></SPIntervalSeconds>
  21. <Notes></Notes>
  22. <ClientName>Client 1</ClientName>
  23. <MMOProviderName>MMO provider 1</MMOProviderName>
  24. <SeismicContractorName>Seismic contractor 1</SeismicContractorName>
  25. </Survey>
  26. </Survey_Data>
  27. </Data>
To copy to clipboard, switch view to plain text mode 

XSL:
Qt Code:
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:template match="data">
  4. <html>
  5. <body>
  6. <h1>TEST</h1>
  7. <table border="1">
  8. <tr bgcolor="#343434">
  9. <th>SurveyId</th>
  10. <th>ClientName</th>
  11. </tr>
  12. <xsl:for-each select="Survey_Data/Survey">
  13. <tr>
  14. <td><xsl:value-of select="SurveyId"/></td>
  15. <td><xsl:value-of select="ClientName"/></td>
  16. </tr>
  17. </xsl:for-each>
  18. </table>
  19. </body>
  20. </html>
  21. </xsl:template>
  22. </xsl:stylesheet>
To copy to clipboard, switch view to plain text mode 

Thank you.

Regards
James