Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] XQuery troubles
Forum Update on Monday, May 27th 2025

[SOLVED] XQuery troubles

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nicky j
    wrote on last edited by
    #1

    hey there,

    I have an application thats supposed to link to an XQuery file to find some data in an XML file. However when I run the application, I get this error (overall the app still compiles and everything except this feature is usable):

    @Error XPST0003 in file:sidebarQuery.xq, at line 1, column 1: syntax error, unexpected end of file@

    my question is twofold:

    1. what does this error mean?
      2)how do I fix it?

    I am assuming that the error is stemming from the XQuery file, not the Qt C++ but I could be wrong.
    I know that this forum and Qt as a whole are not really involved with XQuery, but this forum seems like the best one to ask. If you would like I can post my C++, XQuery, and XML.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      Guessing that it immediately fails with "at line 1, column 1: syntax error, unexpected end of file" I would say that the "sidebarQuery.xq" was not found. It's a relative path, so the file needs to exist in the current working directory of the running process, which is most probably not the same as the source directory.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nicky j
        wrote on last edited by
        #3

        The file resides in an arbitrary file on my computer, but I used the file path when I set it as the query in the C++. How do I place it in the current working directory?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisW67
          wrote on last edited by
          #4

          If you used a full path then you should not need to place it in the current working directory.

          You can determine the current working directory of the process with QDir::current() or QDir::currentPath(). This is a changeable value but is usually set by the IDE when launching the process, or by the desktop icon that launches the process.

          You can place the file with the application executable and use QCoreApplication::applicationDirPath() to locate it.

          The usual approach for small files that form part of your application is to use the Qt Resource system to embed the file in your executable. They cannot get lost that way.

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nicky j
            wrote on last edited by
            #5

            Ok so I found a typo in the file path, but now when I run it I get a new error:
            @Error FORG0001 in file:///Users/nick/Desktop/files for NovaBrowser/sidebarQuery.xq, at line 3, column 41: It's not possible to cast the value of type xs:untypedAtomic to xs:double@

            heres my c++:
            @QFile xqueryFile("/Users/nick/Desktop/files for NovaBrowser/sidebarQuery.xq");
            xqueryFile.open(QIODevice::ReadWrite);

            QXmlQuery query;
            query.setQuery(&xqueryFile, QUrl::fromLocalFile(xqueryFile.fileName()));
            
            QString result;
            query.evaluateTo(&result);@
            

            and XQuery code:
            @xquery version "1.0";

            doc("sidebarApps.xml")/sidebarapps/app[pos = 1]/name
            @

            Thanks!

            1 Reply Last reply
            0
            • N Offline
              N Offline
              nicky j
              wrote on last edited by
              #6

              any clue on how to make this work?

              1 Reply Last reply
              0
              • N Offline
                N Offline
                nicky j
                wrote on last edited by
                #7

                I am still having a lot of trouble with this

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved