Re: [Xsltforms-support] Cancelling loop/action
Brought to you by:
alain-couthures
From: Alain C. <ala...@ag...> - 2021-02-14 08:31:18
|
<!doctype html> <html> <head> <meta charset="UTF-8"> </head> <body> <div> Hi Josselin, </div> <div class="default-style"> <br> </div> <div class="default-style"> It works for me with XSLTForms 1.5.2. Next major XSLTForms release (1.6?) is not yet released (it is using a new XPath 3.0 engine which is transpiling expressions into Javascript functions...). </div> <div class="default-style"> <br> </div> <div class="default-style"> Could you please try again with an empty browser cache? </div> <div class="default-style"> <br> </div> <div class="default-style"> Thanks! </div> <div class="default-style"> <br> </div> <div class="default-style"> --Alain </div> <blockquote type="cite"> <div> Le 13/02/2021 21:45, Josselin Morvan <mor...@gm...> a écrit : </div> <div> <br> </div> <div> <br> </div>Hi Alain, <div class=""> <br class=""> </div> <div class=""> Thank you very much for your feedback. I tried what you suggest, unfortunately, if it works perfectly with XSLTForms 1.3, it doesn’t with XSLTForms 1.5.3, the last submission is still activated twice with this release. </div> <div class=""> <br class=""> </div> <div class=""> Thanks for your help, </div> <div class=""> Best, </div> <div class=""> Josselin. <br class=""> <div> <br class=""> <blockquote type="cite"> <div class=""> Le 13 févr. 2021 à 17:51, Alain Couthures <<a class="" href="mailto:ala...@ag...">ala...@ag...</a>> a écrit : </div> <div class=""> <div class=""> <div class=""> Hi Josselin, </div> <div class="default-style"> <br class=""> </div> <div class="default-style"> In this test case, an event is defined so two submissions are to be sent synchronously, one after one, according to a condition which should be true for one only. The first one will send again the same event producing a submission loop effect. But the first one is also altering the loop condition and it appears that, at the end, the 2 submissions are sent for the same event just before the latest event being caught. </div> <div class="default-style"> <br class=""> </div> <div class="default-style"> The easiest way to control this is to invert the order of the submissions: the one to be activated at the end is to be tested <span class="" style="text-decoration: underline;">before</span> the one to be activated repeatedly. </div> <div class="default-style"> <br class=""> </div> <div class="default-style"> <div class=""> <xf:action ev:event="submission"> </div> <div class=""> <xf:send if="not(instance('sub')/xpr:person[@localType='new'])" submission="submitBio"/> </div> <div class=""> <xf:send if="instance('sub')/xpr:person[@localType='new']" submission="submitNewPerson"/> </div> <div class=""> </xf:action> </div> <div class=""> <br class=""> </div> </div> <div class="default-style"> Thank you for your feedback! </div> <div class="default-style"> <br class=""> </div> <div class="default-style"> --Alain </div> <blockquote type="cite"> <div class=""> Le 06/02/2021 14:42, Josselin Morvan <<a class="" href="mailto:mor...@gm...">mor...@gm...</a>> a écrit : </div> <div class=""> <br class=""> </div> <div class=""> <br class=""> </div> <div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""> Hi Steven, Hi Alain, <div class=""> <br class=""> </div> <div class=""> I made a short and simple sample to show you how my form works, what it does, and the error I get with the submission. </div> <div class=""> <br class=""> </div> <div class=""> Because I run it with BaseX, I added a little Xquery script that creates the db and allows the saving of the submissions. </div> <div class=""> If you want to use it, just put the form file into basex/webapp/static folder and the Xquery file into basex/webapp/ folder. It is a little REST application, just run basexhttp, then go to <a href="http://localhost:8984/xforms/install" class="">http://localhost:8984/xforms/install</a> to create the db, and to <a href="http://localhost:8984/static/xsltforms/submissionLoop.xml" class="">http://localhost:8984/static/xsltforms/submissionLoop.xml</a> to access the form. </div> <div class=""> <br class=""> </div> <div class=""> You can access the files on my Github Gist : <a href="https://gist.github.com/sardinecan/64451cf122095178159804e1ea13b4e5" class="">https://gist.github.com/sardinecan/64451cf122095178159804e1ea13b4e5</a> </div> <div class=""> <br class=""> </div> <div class=""> As you’ll see, I have two submissions, one for the added persons, which is looping as long as there are new persons, and a second one for the main instance which is running when all the new persons have been submitted. </div> <div class=""> <br class=""> </div> <div class=""> I use the dispatch method, with the xforms-submit-done event, and a @delay : </div> <div class=""> <br class=""> </div> <div class=""> <div style="margin: 0px; font-stretch: normal; line-height: normal; background-color: #3c3c3c;" class=""> <span style="color: #5fc8fd;" class=""><xf:action</span><span style="color: #ff8d54;" class=""> ev:event</span><span style="color: #ff8040;" class="">=</span><span style="color: #e06a53;" class="">"xforms-submit-done"</span><span style="color: #5fc8fd;" class="">></span><span class=""><br class=""></span><span style="color: #e5e5e5;" class=""><span style="caret-color: #e5e5e5;" class=""> </span></span><span style="color: #5fc8fd;" class=""><xf:dispatch</span><span style="color: #ff8d54;" class=""> name</span><span style="color: #ff8040;" class="">=</span><span style="color: #e06a53;" class="">"submission"</span><span style="color: #ff8d54;" class=""> targetid</span><span style="color: #ff8040;" class="">=</span><span style="color: #e06a53;" class="">"model"</span><span style="color: #ff8d54;" class=""> delay</span><span style="color: #ff8040;" class="">=</span><span style="color: #e06a53;" class="">"1"</span><span style="color: #5fc8fd;" class="">/></span><span class=""><br class=""></span><span style="color: #5fc8fd;" class=""></xf:action></span> </div> </div> <div class=""> <span style="color: #5fc8fd;" class=""><br class=""></span> </div> <div class=""> Then I have a "if" rule to select the submission to run : </div> <div class=""> <br class=""> </div> <div class=""> <div style="margin: 0px; font-stretch: normal; line-height: normal; color: #e06a53; background-color: #3c3c3c;" class=""> <span style="color: #5fc8fd;" class=""><xf:action</span><span style="color: #ff8d54;" class=""> ev:event</span><span style="color: #ff8040;" class="">=</span>"submission"<span style="color: #5fc8fd;" class="">></span><span class=""><br class=""></span><span style="color: #e5e5e5;" class=""> </span><span style="color: #5fc8fd;" class=""><xf:send</span><span style="color: #ff8d54;" class=""> if</span><span style="color: #ff8040;" class="">=</span>"instance('sub')/xpr:person[@localType='new']"<span style="color: #ff8d54;" class=""> submission</span><span style="color: #ff8040;" class="">=</span>"submitNewPerson"<span style="color: #5fc8fd;" class="">/></span><span class=""><br class=""></span><span style="color: #e5e5e5;" class=""> </span><span style="color: #5fc8fd;" class=""><xf:send</span><span style="color: #ff8d54;" class=""> if</span><span style="color: #ff8040;" class="">=</span>"not(instance('sub')/xpr:person[@localType='new'])"<span style="color: #ff8d54;" class=""> submission</span><span style="color: #ff8040;" class="">=</span>"submitBio"<span style="color: #5fc8fd;" class="">/></span><span class=""><br class=""></span><span style="color: #e5e5e5;" class=""> </span><span style="color: #5fc8fd;" class=""></xf:action></span> </div> </div> <div class=""> <span style="color: #5fc8fd;" class=""><br class=""></span> </div> <div class=""> Like Steven suggests, I think now that there is a submission activated twice, as the submission#submitBio is running two time and it shouldn’t, but maybe I’m doing something wrong ? </div> <div class=""> <br class=""> </div> <div class=""> Thanks a lot for your help, </div> <div class=""> Best, </div> <div class=""> Josselin. </div> <div class=""> <br class=""> <div class=""> <br class=""> <blockquote type="cite"> <div class=""> Le 5 févr. 2021 à 10:54, Steven Pemberton <<a href="mailto:ste...@cw..." class="">ste...@cw...</a>> a écrit : </div> <div class=""> <div class=""> Although submissions are by default asynchronous, a submission element may only be activated once at a time. I'm surprised that all the event values are empty; they really shouldn't be for an xforms-submit-error event. <div class=""> <br class=""> </div> <div class=""> There is a difference in semantics between a dispatch with and without a delay, even if the delay is 0, so try making the delay 0, it should still work. The fact that it works with my original dispatch method suggests that the problem is indeed with a submission being activated twice, but my reading of the spec is that it should be possible once submit-done has been dispatched. I will raise this with the working group. </div> <div class=""> <br class=""> </div> <div class=""> Best wishes, </div> <div class=""> <br class=""> </div> <div class=""> Steven <br class=""> <br class="">On Thursday 04 February 2021 23:42:37 (+01:00), Josselin Morvan wrote: <br class=""> <br class=""> <blockquote> Hi Steven, <div class=""> <br class=""> </div> <div class=""> Thank you for your quick response. Unfortunately, all the error events are empty. </div> <div class=""> So, I tried your method with the dispatch element. At first it didn’t work either, then I added a delay to the dispatch and… it works! </div> <div class=""> <div class=""> As I said, when the submission is done, I update my instance with the server’s response (@xml:id and @localType value, etc.) and then I perform the next submission, maybe all these actions are asynchronous or performed simultaneously, and it produces a conflict? The @delay would allow to really execute the next submission at the end of the entire process? </div> <div class=""> <br class=""> </div> <div class=""> Best, </div> <div class=""> Josselin. </div> <div class=""> <br class=""> <blockquote type="cite"> <div class=""> Le 4 févr. 2021 à 22:25, Steven Pemberton <<a href="mailto:ste...@cw..." class="">ste...@cw...</a>> a écrit : </div> <div class=""> <span style="display: inline; float: none; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-decoration-line: none; -webkit-text-stroke-width: 0px; word-spacing: 0px; white-space: pre; text-transform: none; text-indent: 0px; text-align: start; letter-spacing: normal; font-weight: normal; font-variant-caps: normal; font-style: normal; font-size: inherit; font-family: monospace; color: #0000ff; caret-color: #0000ff;" class=""><message>Submission error. error-type: <output value="event('error-type')"/> error-message: <output value="event('error-message')"/> response-status-code: <output value="event('response-status-code')"/> response-reason-phrase: <output value="event('response-reason-phrase')"/> resource-uri: <output value="event('resource-uri')"/> </message></span> </div> </blockquote> </div> <br class=""> </div> </blockquote> <br class="">-- <br class=""> </div> </div> </div> </blockquote> </div> <br class=""> </div> </div>_______________________________________________ Xsltforms-support mailing list <a class="" href="mailto:Xsl...@li...">Xsl...@li...</a> <a class="" href="https://lists.sourceforge.net/lists/listinfo/xsltforms-support">https://lists.sourceforge.net/lists/listinfo/xsltforms-support</a> </blockquote> </div> </div> </blockquote> </div> <br class=""> </div> </blockquote> </body> </html> |