Results 1 to 2 of 2

Thread: QtXmlPatterns problem

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QtXmlPatterns problem

    Hi all. I've just started experimenting around with XQuery and the QtXmlPatterns module. I've
    put together a small example application but it results in a Segfault. The test.xql script however
    works just fine when processed by the patternist command or Saxon. It's also noteworthy that
    changing
    Qt Code:
    1. ...
    2. for $value in doc("test.xml")/test/entries/entry[@attr = 'y']
    3. return $value
    To copy to clipboard, switch view to plain text mode 
    to
    Qt Code:
    1. ...
    2. for $value in doc("test.xml")/test/entries/entry[@attr = 'y']
    3. return string($value)
    To copy to clipboard, switch view to plain text mode 
    fixes the problem. But for now I want to play around with the nodes, not with the Atomic values they contain.

    Main.cpp:
    Qt Code:
    1. #include <QtGui>
    2. #include <QtXmlPatterns>
    3.  
    4. int main(int argc, char* argv[])
    5. {
    6. QApplication app(argc, argv);
    7. QXmlQuery query;
    8.  
    9. QFile f("test.xql");
    10. if (!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
    11. qDebug() << "couldn't open query file.";
    12. return 1;
    13. }
    14.  
    15. query.setQuery(&f);
    16. if (!query.isValid()) {
    17. qDebug() << "query not valid.";
    18. return 1;
    19. }
    20.  
    21. QXmlResultItems results;
    22. query.evaluateToResult(&results);
    23.  
    24. for (QXmlItem item = results.next(); !item.isNull(); item = results.next()) {
    25. if (item.isAtomicValue()) {
    26. qDebug() << item.toAtomicValue().toString();
    27. } else
    28. qDebug() << "encountered node";
    29. }
    30. return 0;
    31. }
    To copy to clipboard, switch view to plain text mode 
    XQuery script (test.xql):
    Qt Code:
    1. for $value in doc("test.xml")/test/entries/entry[@attr = 'y']
    2. return $value
    To copy to clipboard, switch view to plain text mode 
    Xml File (test.xml):
    Qt Code:
    1. <test>
    2. <entries>
    3. <entry attr="x">Value 1</entry>
    4. <entry attr="y">Value 2</entry>
    5. <entry attr="z">Value 3</entry>
    6. </entries>
    7. </test>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    258
    Thanks
    22
    Thanked 19 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QtXmlPatterns problem

    Just upgraded to the newest Snapshot and realised that the issue is gone .

Similar Threads

  1. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  2. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  3. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  4. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.