Results 1 to 5 of 5

Thread: QXmlQuery not transforming XSL

  1. #1
    Join Date
    Jun 2009
    Posts
    3
    Qt products
    Platforms
    MacOS X Windows

    Unhappy QXmlQuery not transforming XSL

    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

  2. #2
    Join Date
    Jun 2009
    Posts
    3
    Qt products
    Platforms
    MacOS X Windows

    Default Re: QXmlQuery not transforming XSL

    Still no luck, can any one shed some light on what I may be doing wrong?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QXmlQuery not transforming XSL

    What is the output you receive? Did you make sure the data is loaded correctly?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Jun 2009
    Posts
    3
    Qt products
    Platforms
    MacOS X Windows

    Default Re: QXmlQuery not transforming XSL

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QXmlQuery not transforming XSL

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 3
    Last Post: 1st October 2009, 23:19
  2. QXmlQuery XSLT stripping whitespace
    By simula67 in forum Qt Programming
    Replies: 2
    Last Post: 4th June 2009, 08:50
  3. Help needed with QXmlQuery
    By NoRulez in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2008, 12:25
  4. Possible to execute QXmlQuery on a QString?
    By chadkeck in forum Qt Programming
    Replies: 3
    Last Post: 8th October 2008, 17:24
  5. Can't get QXmlQuery to return results
    By bpetty in forum Newbie
    Replies: 2
    Last Post: 13th May 2008, 14:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.