Lazy evaluation of sequence constructors - instructions with side effects evaluated early
I have a problem with Saxon-JS. It seems to be related with either some optimization or, more likely, with concurrency.
I have a template that calls a named template "deactivate" (it modifies the current page sothat it looks disabled).
After that, it schedules an action for loading an external document (ixsl:schedule-action). The scheduled action is a named template that renders the document (<xsl:apply-templates select="doc(someurl)">). After rendering the document, it calls a named template "reactivate", which undoes the work of the earlier "deactivate".
I added a lot of xsl:messages, and in the console of Chrome, I see that template "reactivate" is sometimes called earlier than "deactivate". This seems to be especially the case when the doc() function has been passed a URL that it has seen before (so XSLT need not physically reload the document).
The "deactivate" template has the following structure:
-- message "inside for-each"
Looking at the output in the Chrome console, the messages of the for-each show up at a strange moment, for example when the "completed" message of the entire template has already been printed.
I do recognize the fact that I may be doing things wrong, but I hope that you can shed some light on this. And if it does appear to be a bug, I think you want to know.
Now the application is relatively complex (and written in a mixture of Dutch, English and even a small amount of PHP), so if you are willing to investigate, perhaps I can give some instructions on how to reproduce the problem or even share my screen - I will be most happy to offer any help that is needed. Also, if I need to attempt to reduce the size of the application, let me know.
The behaviour is also seen in Firefox, but in my Firefox, xsl:messages are not shown in the console.
I attach the files plus a screen selection of the Chrome console. The numbers indicate, more or less, the expected order of messages.
Please register to edit this issue