Hi Christian,
Thank you for the fast answer. Actually, using a non-updating expression is exactly what I did, except that validation is done in the calling application, as validate:xsd(...) merely supports a single schema. So it results in 2 queries, one non-updating query performing the update operations before validation and a second one that performs the "real" update after validation was successful. Are there plans to extend validate:xsd(...) to support multiple schemas in upcoming releases?
Best regards,
Julien Charon
Avitech GmbH Engineering AxL Tel.: +49 (0)7541/282-177 Fax: +49 (0)7541/282-199 e-mail: julien.charon@avitech.aero ________________________________________________ Avitech GmbH Principal Office: Bahnhofplatz 1 | 88045 Friedrichshafen | Germany Court Registration: Amtsgericht Ulm | HRB 728293 Geschäftsführer/Managing Director: Antonio Maria Gonzalez Gorostiza http://avitech.aero
This message may contain confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. -----Ursprüngliche Nachricht----- Von: Christian Grün [mailto:christian.gruen@gmail.com] Gesendet: Donnerstag, 18. September 2014 13:37 An: Julien Charon Cc: basex-talk@mailman.uni-konstanz.de Betreff: Re: [basex-talk] Transaction (rollback)
Hi Julien,
So, what we first thought of was creating a transaction, executing the update/replace operations, perform the validation, and if the result of the operations result in invalid XML, perform a rollback.
I would recommend you to use a non-updating expression [1], validate the result and store it in a second step. The query could look as follows:
let $input := db:open('db')/a/b/c let $result := copy $c := $input modify delete node $c//text() return $c return try { validate:xsd($result, 'schema.xsd'), (: validation was successful... :) replace node $input with $result } catch BXVA0001 { db:output("Validation failed: " || $err:description) }
Rollback features are on our agenda and may be introduced along with MVCC or even earlier, but I cannot give any timeline yet.
Hope this helps, Christian
[1] http://docs.basex.org/wiki/XQuery_Update#Non-Updating_Expressions