Inserting and removing data with QXmlQuery

  • Hello,

    I would like to know if it is possible to insert/modify/remove data with an XQuery using QXmlQuery?

    I found an "exemple": of XQuery updating some data with the following query but I am not able to run it:
    @for $idattr in doc("data.xml")//ITEM/@Id (: selection :)
    return (
    delete node $idattr, (: update 1 :)
    insert node <NID>{string($idattr)}</NID> (: update 2 :)
    as first into $idattr/..
    I have the following error :
    syntax error, unexpected node, expecting )

    If it is not possible to use insert or delete how I am suppose to modify the content of a document?


  • Hello
    I had the same problem. It is looks like that Qt currently only supports "Minimal Conformance" and yet does not support optional XQuery features as it is described here:

    QXMLQuery Features and Conformance:

    XQuery 1.0
    Qt XML Patterns aims at being a conformant XQuery processor. It adheres to Minimal Conformance and supports the Serialization Feature and the Full Axis Feature. Qt XML Patterns currently passes 97% of the tests in the XML Query Test Suite. Areas where conformance may be questionable and where behavior may be changed in future releases include:
    Some corner cases involving namespaces and element constructors are incorrect.
    XPath is a subset of XQuery and the implementation of Qt XML Patterns uses XPath 2.0 with XQuery 1.0.
    The specifications discusses conformance further: XQuery 1.0: An XML Query Language. W3C's XQuery testing effort can be of interest as well, XML Query Test Suite.
    Currently fn:collection() does not access any data set, and there is no API for providing data through the collection. As a result, evaluating fn:collection() returns the empty sequence. We intend to provide functionality for this in a future release of Qt.
    Only queries encoded in UTF-8 are supported.

    And here is the relation of XQuery update with "Minimal Conformance"

    So I guess this feature is not included in the current version of QXMLQuery

    Instead it is possible to use QDomDocument.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.