RE: JavaScript to XForms Conversion

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 UTC