Hi Alain, Just for background, many of these enhancements were necessary to
make it possible to run XSLTForms as offline forms (compare InfoPath).
- Some deeper changes were required to make XSLTForms work in Chrome App
context. Google Chrome imposes some unfortunate restrictions on browser apps,
including 1) banning synchronous XMLHttpRequests and 2) forbidding inline
scripts. To cope with the former, XSLTForms' init functions had to be rewritten
as async functions with continuation callbacks, and for the latter,
xsltforms.xsl had to be extended with an option to output scripts into separate
resource files (I am using an XSLT 2.0 stylesheet that includes xsltforms.xsl),
which in turn required some changes to XSLTForms' subform loading scripts for
example. Maybe such extensive changes are not required for apps in other
browsers, however, Chrome still offers significant advantages (speed, app
deployment options, ...) which justified these efforts. File access, as well as
local storage access, required extending the submission module to interface
with the chrome.fileSystem and chrome.storage.local APIs.
- I implemented a separate transform() function in the saxon namespace, however
I agree that the solution you propose would be much more elegant. The trickiest
thing with including the SaxonCE library was to tweak it such that it loads
synchronously as a normal js library! Having access to XSLT 2.0 can be quite
useful in offline forms where one cannot call upon a server to do
transformations, schematron validation etc.!
- True, in Web Worker context there is no access to the page document object. A
few deeper changes were required to XSLTForms code to allow fairly arbitrary
XPath expressions to be evaluated in Web Worker context. Some of the XPath
function implementations in XSLTForms depend on the page document object which
is not available in Web Worker context and also not sensible to serialize. I
solved it by making sure functions access all their resources via the XPath
evaluation context object (which had to be extended with a reference to the
XForms model object), and serialized to a proper depth.
- For XML schema validation, I am calling the following library:
https://github.com/hubgit/xml.js/tree/dtd-validation. I think it works in all
browsers!
- Both validation functions are currently XPath extension functions (maybe they
could be implemented as extension actions instead -- or as emulated web-service
operations accessible via the submission element so as to keep things
standard?). I use them in my offline forms to validate instance documents
opened by the user from the file system, or for validating form entries with an
approach similar to this:
http://wiki.orbeon.com/forms/how-to/logic/external-validation, not requiring
calling an external service. I have them evaluated in a non-blocking background
thread using the @async='true' extension.
- parse-xml() (which by the way seems to be a standard function in a more
recent version of XPath) replaces xf:setnode in the following way:
<xf:insert nodeset="instance('data')" origin="parse-xml(transform(...))"/> (for
example)
- Another often needed improvement I've implemented is the
xf:select1/@selection="open" (i.e. combobox). It's a simple change that
leverages the HTML 5 @datalist.
I will think how to best share these extensions! Whatever makes it easier to
potentially have some of these make it into the official version! :)
Kind regards,Mats
On Sun, 10 Apr 2016 21:45:52 +0200 [email protected] wrote:
Hi Mats,
- Allowing XSLTForms to be run as Chrome Apps, with
file save/open functionality etc.
Could you please write some documentation about how you succeeded?
It might be added in XSLTForms Wikibook, for example.- Embedding SaxonCE
library so that transform()
function can run XSLT2 transforms
Have you modified the transform() function so that it is looking at
the version of the stylesheet? Could this better be considered as a
global option to be added in config files?- Adding @async attribute to
xf:setvalue/xf:insert
elements for non-blocking evaluation of long running
XPath expressions in Web Workers
Web Workers are not available in old browsers but all recent ones do
now! I did not try to use them yet (priorities...) and I still
wonder how they can access the XML DOM in the main page: is it a
problem??- Adding validate-with-xml-schema() function, using
xmllint library
Is it that Chrome Apps allow you to link C libraries?- Adding
validate-with-schematron() function, using
SaxonCE. Useful for doing more advanced form
validations using SVRL.
Is it an XPath function? When are you calling it? Before submission?
XForms is based on validation at node level whenever a value has
been modified: do you think that it is also compatible with SVRL?- Adding
parse-xml() function, believe replacing
need for xf:setnode
xf:setvalue is there to set a value not to import nodes... That's
why I added xf:setnode with the serialized XML string as parameter.
In what context do you use parse-xml()? Which document/instance owns
the resulting nodes?
Would be glad to contribute these as well as some
other extensions and performance optimizations.
Will be glad to look at them in details!! Is it your intent to
publish source files independently or to fork the repository?
Thanks!
Alain
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Xsltforms-support mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xsltforms-support