Hi everybody,
I have questions regarding transactions in basex. To provide a context, we have following requirements in our application that uses basex: when executing any update or replace operations, we need to validate the modified XML structures against the corresponding schemas. We only want the result of the update / replace operations to be saved in basex, if the resulting XML structures are valid. 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. Now we weren't able to find documentation concerning rollback, the only documentation we found is http://docs.basex.org/wiki/Transaction_Management, which does not mention rollback.
So my questions are:
1. Is there a rollback functionality and where can I find documentation?
2. If there is no rollback functionality, is it planned for upcoming releases?
3. Are there best practices for the requirements described above? Note: using the validation module is not an option, as apparently only single schemas / schema files are supported and our application schemas are quite complex and located in several schemas, so validation has to be performed in our application.
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.aeromailto: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.aerohttp://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.
________________________________ Avitech GmbH Principal Office: Bahnhofplatz 1 | 88045 Friedrichshafen | Germany Court Registration: Amtsgericht Ulm | HRB 728293 Geschäftsführer/Managing Director: Antonio Maria Gonzalez Gorostiza VAT No.: DE223719716 http://avitech.aero
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
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
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?
I am not quite sure if that's really a necessary requirement. Have you tried to execute validate:xsd multiple times in one query?
C.
Hi Christian,
Sorry, I should have explained the situation in detail. We actually have several schemas that depend on each other due to hierarchial structures. So, e.g. A.xsd depends on B.xsd which depends on C.xsd. Now, the different schemas are not available on the file system (actually they are dynamic and can be replaced at runtime) and our application cannot access external URIs , so we need to identify the depending schemas by their target namespace. That is, when I call validate:xsd using A.xsd, it's unable to find the schemas for B.xsd and C.xsd. I wrote this in java using a resource resolver. But as I describe all that I realise that our situation is very special, so there may in fact be no need to support multiple schemas. However, I could imagine there are other applications that cannot access external URIs, so the only solution would be to modify the schema locations in all schemas needed by an application to point to the an accessible file system, but that's not basex specific.
Best regards,
Julien
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:52 An: Julien Charon Cc: basex-talk@mailman.uni-konstanz.de Betreff: Re: [basex-talk] Transaction (rollback)
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?
I am not quite sure if that's really a necessary requirement. Have you tried to execute validate:xsd multiple times in one query?
C.
basex-talk@mailman.uni-konstanz.de