W3C home > Mailing lists > Public > www-forms@w3.org > January 2004

RE: JavaScript to XForms Conversion

From: Mark Birbeck <mark.birbeck@x-port.net>
Date: Mon, 26 Jan 2004 19:05:31 -0000
To: "'Ronald Kent Gibson'" <Kent.Gibson@icongmbh.de>
Cc: <www-forms@w3.org>
Message-ID: <001e01c3e43f$5e655e40$6b01a8c0@W100>

Ronald,

> Does anyone know of any work going on in regards to
> conversion/translation of javascript code commonly
> found in web forms to xforms. For example a tool or
> an api, that someone is working on. My searches come
> up with nothing.

It would be quite a job to convert procedural code to declarative.


> Another General question,  If I was to build a tool to
> convert say an html form to an xform, but simply copy
> over the javascript and embed it somehow (presumably with
> a script tag) how messy a solution would this be?

Well ... quite messy, but not the end of the world. There is nothing to
say that you can't have script in an HTML/XHTML document that contains
XForms. Obviously there are many, many tasks that are currently
performed with script that can be handled by declarative statements in
XForms, but that doesn't mean that what you are proposing is not a
legitimate migration path.

A couple of things that might help; first, XForms allows some of its
features to be invoked via a method call. For example, you can force a
rebuild or refresh on a model. So if your script directly manipulated a
DOM that was also instance data, you could still bring the data and UI
into line. For example:

    <script language="JScript">
      function changeGreeting()
      {
        var theModel = document.getElementById("mdlGreeting");
        var theInstance = theModel.getInstanceDocument("data");
        var theNode = theInstance.selectSingleNode("//who");

        theNode.text = "Father Christmas";
        theModel.refresh();
      }
    </script>


Secondly, in formsPlayer we have allowed the XForms event model to cross
over into the HTML 4 event model, even though they are different. The
upshot of this is that you can use IE script tags in formsPlayer, and
wire them into XForms events. For example:

    <xforms:submission
     id="subTaskSave"
     action="taskList.xml"
     method="put"
     replace="none"
    />
    .
    .
    .
    <script for="subTaskSave" event="xforms-submit-done">
       alert("file saved ...");
    </script>

Whilst I would say that your general approach of converting a whole load
of HTML pages en masses to XForms will probably be quite difficult, I
think you might find that gradually inserting more and more XForms
mark-up into your HTML may not be a bad migration path.


> and lastly, are there any pdf forms to xforms or xforms to pdf forms
> tools\apis\solutions that anyone has heard about?

I've not heard of anything.

Regards,

Mark


Mark Birbeck
CEO and CTO
x-port.net Ltd.

Download formsPlayer from
http://www.formsPlayer.com/
Received on Monday, 26 January 2004 14:09:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Saturday, 10 March 2012 06:21:57 GMT