[SOLVED] XQuery troubles

  • 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.

  • 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.

  • 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?

  • 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.

  • 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");

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

    and XQuery code:
    @xquery version "1.0";

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


  • any clue on how to make this work?

  • I am still having a lot of trouble with this

Log in to reply