Results 1 to 2 of 2

Thread: bug XPath in XSLT?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Russia, Nizhny Novgorod
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default bug XPath in XSLT?

    Hello all,

    I've the following simple code scratch:
    Qt Code:
    1. QCoreApplication xApplication(argc, argv);
    2.  
    3. QXmlQuery xQuery(QXmlQuery::XSLT20);
    4. QBuffer xOriginalContent;
    5. QString xXMLContent = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><folder id=\"0\" name=\"root\" is_expanded=\"false\"></folder>";
    6. xOriginalContent.setData( xXMLContent.toAscii() );
    7. xOriginalContent.open(QBuffer::ReadWrite);
    8. xOriginalContent.reset();
    9.  
    10. xQuery.setFocus(&xOriginalContent);
    11. QString xRequestString;
    12. xRequestString += "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
    13. "<xsl:stylesheet version=\"2.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">"
    14. " <xsl:template match=\"/\">"
    15. " <xsl:apply-templates/>"
    16. " </xsl:template>"
    17. " <xsl:template match=\"folder\">"
    18. " <folder name=\"{@name}\" id=\"{@id}\" is_expanded=\"{@is_expanded}\">"
    19. " <xsl:copy-of select=\"child::node()\"/>"
    20. " <xsl:if test=\"@id=0\">"
    21. " <folder id=\"1\" name=\"name\"> </folder>"
    22. " </xsl:if>"
    23. " </folder>"
    24. " </xsl:template>"
    25. " <xsl:template match=\"*\">"
    26. " <xsl:copy-of select=\".\"/>"
    27. " </xsl:template>"
    28. "</xsl:stylesheet>";
    29.  
    30. xQuery.setQuery(xRequestString);
    31. assert(xQuery.isValid());
    32. QBuffer xOutputContent;
    33. xOutputContent.open(QBuffer::ReadWrite);
    34. xOutputContent.reset();
    35. std::string str1(xOriginalContent.data());
    36. xQuery.evaluateTo(&xOutputContent);
    37. xXMLContent = xOutputContent.data() ;
    38. std::string str(xOutputContent.data());
    39.  
    40. return xApplication.exec();
    To copy to clipboard, switch view to plain text mode 
    I expect the following result:
    <folder name="root" id="0" is_expanded="false"><folder id="1" name="name"/></folder>
    but have the following
    <folder name="root" id="" is_expanded=""><folder id="1" name="name"/></folder>
    As you can see two of three XPath expressions(<folder name=\"{@name}\" id=\"{@id}\" is_expanded=\"{@is_expanded}\">) weren't executed at all! Does anyone have the experience with such a problem?
    All your attempts to help will be appreciated

  2. #2
    Join Date
    Mar 2009
    Location
    Russia, Nizhny Novgorod
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: bug XPath in XSLT?

    There is no the issue in qt 4.5.2 anymore. Closed

Similar Threads

  1. QXmlQuery XSLT stripping whitespace
    By simula67 in forum Qt Programming
    Replies: 2
    Last Post: 4th June 2009, 09:50
  2. QtWebkit and XSLT
    By yop in forum Qt Programming
    Replies: 1
    Last Post: 15th October 2008, 10:21
  3. XML + XSLT mit QT
    By NoRulez in forum Qt Programming
    Replies: 3
    Last Post: 11th June 2008, 23:52
  4. XPath
    By steg90 in forum Qt Programming
    Replies: 1
    Last Post: 13th July 2007, 22:55

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.