Results 1 to 6 of 6

Thread: XSLT 'xsl:analyze-string' doesn't work

  1. #1
    Join Date
    Feb 2011
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default XSLT 'xsl:analyze-string' doesn't work

    Hi all,
    I am having trouble with 'xsl:analyze-string'. I have the following source XML:
    Qt Code:
    1. <AUTHOR_CONTACT_INFORMATION>Plugin author can be reached at abc@yahoo.com for his email.</AUTHOR_CONTACT_INFORMATION>
    To copy to clipboard, switch view to plain text mode 

    And I am using the following XSLT:
    Qt Code:
    1. <xsl:analyze-string select="AUTHOR_CONTACT_INFORMATION" regex="(abc@yahoo.com)">
    2. <xsl:matching-substring>
    3. <a href="{regex-group(1)}"><xsl:value-of select="regex-group(1)" /></a>
    4. </xsl:matching-substring>
    5. <xsl:non-matching-substring>
    6. <xsl:value-of select="." />
    7. </xsl:non-matching-substring>
    8. </xsl:analyze-string>
    To copy to clipboard, switch view to plain text mode 

    The idea is to replace email addresses and web links with HTML a href. (In the above example, I've just replaced RegEx expressions to make things easier) Using Qt4's QXmlQuery class as my XSLT processor gives me empty string. Using 'Altova XMLSpy' the above correctly displays the hyperlinked output. Qt4's conformance documentation says Qt4 supports 'xsl:analyze-string'. What am I doing wrong? Are there any working examples using 'xsl:analyze-string'?

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

    Default Re: XSLT 'xsl:analyze-string' doesn't work

    See if the reference examples work: http://www.w3.org/TR/xslt20/#analyze-string
    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.


  3. #3
    Join Date
    Feb 2011
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: XSLT 'xsl:analyze-string' doesn't work

    Here's a simple example I pulled from the link:

    XML:

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <abstract>Hello there!
    3. This is just a test</abstract>
    To copy to clipboard, switch view to plain text mode 

    XSLT:
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
    3.  
    4. <xsl:template match="/">
    5. <html>
    6. <body>
    7. <xsl:analyze-string select="abstract" regex="\n">
    8. <xsl:matching-substring>
    9. <br/>
    10. </xsl:matching-substring>
    11. <xsl:non-matching-substring>
    12. <xsl:value-of select="."/>
    13. </xsl:non-matching-substring>
    14. </xsl:analyze-string>
    15. </body>
    16. </html>
    17. </xsl:template>
    18. </xsl:stylesheet>
    To copy to clipboard, switch view to plain text mode 

    Output from Qt4 app:
    Qt Code:
    1. <html>
    2. <body/>
    3. </html>
    To copy to clipboard, switch view to plain text mode 

    Output from Altova XMLSpy:
    Qt Code:
    1. <html>
    2. <body>Hello there!<br>This is just a test</body>
    3. </html>
    To copy to clipboard, switch view to plain text mode 

    My version of qt is 4.7.0 (32-bit) Windows version downloaded from qt.nokia.com/products . I didn't compile the source myself. And if its relevent, I am running Windows 7 Home 64-bit.

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

    Default Re: XSLT 'xsl:analyze-string' doesn't work

    If the reference example doesn't work then obviously that's a case which is not handled by Qt's XQuery implementation.
    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.


  5. #5
    Join Date
    Feb 2011
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: XSLT 'xsl:analyze-string' doesn't work

    Why does the XSLT Conformance Docs specifically show that it is supported?

    Stating the obvious wasn't the answer I was looking forward to. What could be a work around for this (in XSLT 1.0 maybe)? Currently, as I have to output tags '<' and '>' by escaping them, I am using the following:
    1. using xsl:value-of select= "replace(AUTHOR,_CONTACT_INFORMATION, '(abc@yahoo.com)', '&lt;a href=&quot;$1&quot;&gt;$1&lt;/a&gt;')"
    2. then the output is parsed again in C++ code by replacing '&lt;' and '&gt;' with actual characters

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

    Default Re: XSLT 'xsl:analyze-string' doesn't work

    Quote Originally Posted by Sanje2v View Post
    Why does the XSLT Conformance Docs specifically show that it is supported?
    It doesn't specify what exactly is supported. If you want, find if Qt has an autotest for analyze-string.
    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. Screenshot example doesn't work on Mac OSX
    By Damiano in forum Qt Programming
    Replies: 0
    Last Post: 19th January 2011, 11:17
  2. Why this code doesn't work?
    By prykHetQuo in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2009, 19:08
  3. setTabStopWidth doesn't work
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 19th November 2007, 08:29
  4. setWindowOpacity doesn't work!
    By nupul in forum Qt Programming
    Replies: 5
    Last Post: 21st April 2006, 18:28

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.