Sign In/My Account | View Cart  
advertisement


Listen Print Discuss

What Are XForms
by Micah Dubinko | Pages: 1, 2

Actions sans Script

Other than a few special cases (submit and reset) the way to make today's web forms do something is through scripts attached to "intrinsic" event attributes like onFocus. With the mission of reducing the need for scripts, the HTML Working Group and XForms Working Group have jointly developed a general purpose event framework called XML Events. It provides an XML interface to DOM Level 2 STYLE events. It also enables the definition of markup-based (a.k.a. script-free) XForms Actions.

Using an element-based declarative syntax, XForms authors can:

  • set focus to a form control
  • display a message to the user
  • navigate to a new URI (in the same or a new window)
  • change the value of an instance data node
  • force a recalculation, revalidation, or screen refresh
  • submit or reset all or a portion of the instance data
  • perform other actions to deal with scrolling and manipulating repeating line item tables

In this example, a form authored for a resource-limited device might wish to recalculate only when a trigger is activated:

<xforms:trigger>

  <xforms:label>Click to Recalculate</xforms:label>

  <xforms:action ev:event="xforms-activate">

    <xforms:recalculate/>

  </xforms:action>

</xforms:trigger>

(Note that the xforms prefix represents the XForms namespace and the ev prefix represents the XML Events namespace.)

XForms in XHTML

While the XForms language is suitable for inclusion in any number of other XML document formats, the sweet spot is its combination with XHTML. Working Drafts of XHTML 2.0 indicate that the old forms technology will not be included in the standard, being replaced by XForms.

The following example will walk through a basic form -- collecting a credit card number in the simplest way possible.

XML in a Nutshell

Related Reading

XML in a Nutshell
A Desktop Quick Reference
By Elliotte Rusty Harold, W. Scott Means

In XHTML, a form is completely enclosed within <form>...</form> tags. In contrast, the XForms solution separates purpose, represented by the "XForms Model" (the name for the non-visible form data plus annotations), from presentation, represented by the form controls. This means that adding a single form to a containing document usually involves inserting markup in multiple places.

The XForms Model belongs in the header section or within the <head> element of XHTML:

<html xmlns="http://www.w3.org/2002/06/xhtml2"

  xmlns:xforms="http://www.w3.org/2002/08/xforms/cr">

  <head>

    <title>Example of XHTML plus XForms</title>

      <xforms:model id="myform">

      <xforms:submission action="https://example.com/cc-submit"/>

    </xforms:model>

  </head>

Additionally, form controls belong alongside other markup in the visible portion of the document, which means the <body> element in XHTML:

...

  <p>Enter your credit card number below</p>

  <xforms:input ref="cc">

    <xforms:label>Credit Card:</xforms:label>

  </xforms:input>

  <p>...</p>

  <xforms:submit>

    <xforms:label>Submit</xforms:label>

  </xforms:submit>

...

Initially, HTML forms didn't associate any kind of field-level label with form controls, except for physically positioning the labels near the controls, which was especially difficult for non-visual browsers to interpret. Later versions added an optional label wrapper, but this technique never gained widespread usage. Now in XForms, every form control element has a required label child element, which contains the associated label.

Upon submit, the XForms Processor would deliver serialized instance data -- which looks something like

<instanceData>

  <cc>123423453456</cc>

</instanceData>
-- where the element name is determined by the binding expression attached to the input element. In more advanced settings, separate instance data can define arbitrarily complex XML structures processed through XForms.

What It Means

What does the future hold for XForms? One certainty is that connected devices are becoming more diverse than ever, appearing in all shapes and sizes. Web forms no longer lead sheltered lives on the desktop. By offering a more flexible, device-independent platform, XForms will provide interactivity on such devices.

Most organizations now have substantial investments in XML. Since XForms technology reads and writes XML instance data, it enables existing investments to be leveraged as building blocks in a larger system more smoothly than with ordinary XHTML forms. Additionally, Web Services (or the Semantic Web, depending on your upbringing) will increase the amount of information interchange over the Web, which will in turn increase the need for information to be entered -- through XForms.

Those who have struggled with traditional forms and associated scripting will appreciate the consistent set of form controls and declarative actions in the specification, as well as the powerful and familiar XSLT-like processing model. Calculations, validations, and business logic will also be expressible without scripts.

Updated forms are one of the major changes in XHTML 2.0, the most significant change to HTML since its conception in 1993. Developers and users alike are looking forward to the final W3C Recommendation for XForms.

For More Information

The primary source for information on XForms is the www-forms mailing list. To subscribe, send an email to www-forms@w3.org with the word "subscribe" in the subject line (include the word "unsubscribe" if you want to unsubscribe). The archive for the list is also accessible online.

To play with the latest XForms specification, you can use the latest published Schema, or try out one of the following early implementations:

The open source X-Smiles browser supports an impressive array of standards, including XForms, SVG, SMIL, and XSL formatting objects. E-XMLMedia has developed a Java applet-based version, which is available as a commercial product, with an evaluation version available upon request. Additionally, Mozquito is working on a Flash implementation, with details posted on an editable weblog done in XForms. (Warning: this link requires an XForms browser) More implementations are coming online soon.


Comment on this articleGot questions about XForms? Ask them here.
(* You must be a
member of XML.com to use this feature.)
Comment on this Article


Titles Only Titles Only Newest First
  • christmas lights installation los angeles 310 295 0153
    2009-11-21 12:18:59 herscko [Reply]

    xmas christmas,holiday decorations,string lights,christmas light installation,hang christmas lights light installation,christmas decorating service,christmas decorations.
    Residential & commercial holiday decorating services of christmas light
    installation,ground lighting,decorating with wreaths for the holiday season,
    placing garland, decorating christmas trees, and many other holiday and
    christmas decorating services available.
    Professional installers know how much your home means to you, they
    use property-friendly installation methods
    and use extreme care to take care of what is yours.
    The outdoor christmas lighting installation process takes place with
    little aggravation to existing landscaping.
    Christmas Light Installation Los Angeles
    Christmas, Lights, homes, hotels, residential, commercial, holiday,
    decorating bussiness, hang, Commercial and Residential Christmas light installation.
    Wreath and seasonal decor hanging. Services for homes,bussiness, shopping centers.
    Christmas outdoor decorations,christmas iawn decoration,holiday decorations
    and lighted decorations for holiday season, everything is handled for you.
    Professional installers know how much your home means to you.
    christmas lights installation los angeles
    call today 310 295 0153

  • AAA Locksmith Los Angeles 1-310-925-1720
    2009-06-11 15:23:14 whats [Reply]

    Locksmith Los Angeles 1-310-925-1720
    #1 24 Hour Locksmith Los Angeles
    call 1-323-678-2704
    Locksmith services Los Angeles, including locks installation, doors locks repair, doors locks rekey, locks and keys products or services the best value and commitment to customers 100 satisfaction guaranteed.
    24 Hour Emergency Locksmiths Service
    Burglary Repairs Los Angeles County


    Professional Lock Repair



    Professional Door Lock Replacement



    Professional Lockout Services



    Professional Door Locks Rekeying



    Immediate Response 24 hours a day



    Doors Locks Installation



    Automotive Locksmith




  • Building XForms scripts?
    2005-06-07 14:04:17 nikkys [Reply]


    XForms seems to be a nice way for building forms with the new webform technology.
    But is it easy to build the XForms scripts..?Is there a tool that we can use to drag and drop controls and create XForms-based webforms?

  • days-from-date()
    2004-12-02 14:54:54 kickiki26 [Reply]

    I'm unable to get a valid result when I use the function days-from-date(). The function always returns a 'NaN' value.

  • XForms Institute
    2004-02-04 10:24:34 Micah Dubinko [Reply]

    For the record, some examples and a tutorial in XForms are available at http://xformsinstitute.com.


    Examples include a 'view source' page, so that you can dig in and see how things really work in the real world.


    Works in all browsers on all platforms, as long as you have a recent Flash player.


    Check it out.

  • Why header information?
    2003-01-17 14:03:19 Michael Long [Reply]

    We build a lot of web sites using a black box/component-type approach. Many times within a page body we'll tell a certain component to display it's form information (include XYZ form here).


    It would seem that xforms will break this approach, as it requires you to specfiy form information in the html HEADER, as well as within the body.


  • XForms not yet ready
    2002-11-19 01:56:42 Stephan Portmann [Reply]

    XForms sounds great but it is not ready yet.


    We are a young, innovative technology company doing "XForms" since 2 years. Check out our online demo:


    http://www.demo.jaxfront.com


    any feedback is apprecicated, email to:
    info@xcentric.ch


    /Stephan Portmann

  • Ubiquitous forms or not?
    2002-11-08 17:34:43 Steven Punte [Reply]

    Certainly HTML needs improvement in forms, along with
    many other areas. However, I have to wonder if the goal
    of having a single markup language for all devices is
    a wise one. If I was a site designer, would I really
    want a small phone like device attempting to implement
    the <range> slide bar? Perhaps there will always be
    server side client device type detection and change
    of behavior for good reasons.

    • Ubiquitous forms or not?
      2006-01-17 09:04:40 GuidoGrassel [Reply]

      Yes, you would like to have the range implemented, because it improves usability. It is easier for the end-user to operate a range control than to type a number using the input method of most embedded devices.


  • what modules
    2002-10-07 22:39:35 suad al-borno [Reply]

    what modules i can use to interpret the validation instructions built into Xforms?

  • XForms & Apache Cocoon
    2002-09-21 21:29:29 Ivelin Ivanov [Reply]

    It is not clear how long before XForms is implemented in the mainstream browsers.


    Following its tradition with XSLT, Cocoon attempts to provide a solution for today's technology with a perspective to push complexity to the client when the time comes.


    http://xml.apache.org/cocoon/userdocs/concepts/xmlform.html


    I would be interested to hear what people think about Cocoon's choice to implement a server side subset of XForms.


    • XForms & Apache Cocoon
      2004-02-03 05:52:05 Erik Wilde [Reply]

      afaik, xmlforms is no longer supported in cocoon and has been replaced by jxforms:


      http://cocoon.apache.org/2.1/userdocs/flow/jxforms.html


      i don't know how that compares to xmlforms and xforms, but the issue of transition strategies certainly is an important one.


      since microsoft has released infopath, it is not very likely that they will support xforms with great enthusiam. and if xforms support is not going to be included in ie, then xforms has a serious problem.

  • XFORMS and Schema's
    2002-09-11 07:52:41 Marc van der Zee [Reply]

    We have developed a schema for the exchange of building material information.
    We are new to Xforms (who isn't?) but we are considering to build the front end application for creating the XML-files with Xforms.
    How can we connect our (or a) schema to an Xform so that we can validate the user input without retyping the schema in the form?

  • what about XUL?
    2002-02-04 11:13:52 marcelo alfaro [Reply]

    XUL implements a kind of this and its works now.

    • what about XUL?
      2002-03-21 20:53:22 Reza BFar [Reply]

      Hmmm... Some reasons XForms is better:


      1) XUL is designed with a GUI in mind, not so for XForms. XForms simply models user interactions.


      2) XUL is a mozilla thing. Standard bodies are superior because corporations that produce software for sale or for their own will build software based on specifications of Standard Bodies... W3C, IETF, etc.


      3) IMHO, much more software engineering forethought has gone into XForms. The binding process, instance data, etc. is really very well designed and will withstand the test of time (if XForms becomes pervasive which is more dependent on economic factors than anything else... )

  • XForm to WML
    2001-12-03 16:47:03 Krisnasamy Arumugam [Reply]

    Can anyone describe how to use XForms to output to pda or mobiles?


    Thank you in advance.

    • XForm to WML
      2003-06-16 09:44:31 sean Ginter [Reply]

      Go the schema route instead using a DTD.Or use x-include and combine documents.

    • XForm to WML
      2002-01-22 00:13:22 Sergej Rinc [Reply]

      Well,


      don't you think you would do the same as usual content, tagged in XML (and transformed via XSLT to HTML, WML, text, even PDF etc)?


      As I see it, I could "program" forms with XForms and then use XSLT to transform them to appopriate media/format. For time being HTML or even XHTML for web browser but in a usual, compatible way, since web browsers don't support XHTML natively yet (and thus XForms etc).

  • XForms vs. XFA and XFDL
    2001-11-30 08:40:36 Sébastien Landeau [Reply]

    Can anybody show out the main differences between XForms and the two other technologies XFA and XFDL ???

    • XForms vs. XFA and XFDL
      2002-01-20 18:47:58 Michael Rossi [Reply]

      Hey S,
      I can't say that I'm familiar enough with these specs yet to comment on their differences. But I do know that XFA and XFDL were both submitted and backed independently by two of the traditional forms automation vendors. I believe both of those vendors now have representation on the XForms working group within the W3C. So I'd expect that as soon as the document becomes a recommendation you'll see the earlier specs die off in favor of XForms support.

  • Lets get real...
    2001-10-01 12:14:27 tony r [Reply]

    I am all for XForms - but this will not be ready to even start integration into the "major browsers" for some time. I can see how cool it could be, but it will take years to get this thing to a point where I can recommend it to clients, much less to execs. It is all academic until then...

  • XForms very useful for web apps
    2001-09-18 13:19:33 Jan Dvorak [Reply]

    I believe web applications will be both easier and more fun to build in XML. The designers will fiddle with stylesheets, while we, the programmers, will handle data with XSLT, for the most part. And XForms XForms will cover the weakest spot here: the data input.


    Actually, you do scripting in XForms. It's just that the scripts are written in XSLT, but that's a full-blown programming language! It happens to have a few <>'s in the syntax compared to e.g. JavaScript, but as long as you can manipulate the DOM that represents the form data and structure, you can do pretty much everything. Looking forward to that, it'll be fun.

  • XForms
    2001-09-06 03:10:39 Enrico Granata [Reply]

    Although the technology seems promising, I think the W3C should not turn new ideas into specifications until the existing XML stuff is wholly implemented and widely spread
    Schemas are an example of a useful technology that is still just a technology on paper, the only real-world implementation (IE's) has been out-dated
    I think this is not the way to have XML up and running, it's just a way to make a Science Fiction Movie, without letting anybody watch it, till Science out-dated it...

    • XForms
      2006-01-17 09:18:00 GuidoGrassel [Reply]

      XForms a a lot of dependencies on other XML and other technologies, XML Schema, XPath, XML namespaces, some advanced CSS stuff, ... This is certainly a burden when thinking on how to implement XForms in a Web Browser. Web Browsers are good in HTML, but they still need to "learn" a lot of XML. However, XForms is just one of an increasing nmuber of reasons why Web Browsers will "learn" more XML.
      XForms plugins for IE, XForms implementation for Mozilla are evidence that the job can be done.





    • XForms
      2001-09-09 04:37:17 Sebastian Schnitzenbaumer [Reply]

      I violantly disagree with smartguy16! Why on
      earth do some people think everything the W3C
      produces has to end up in MS IE, and if it *doesn't*, it's a failure? Given this thinking, the W3C should have seized its operations after the browser wars, never releasing such important
      technologies like XML, XSLT, and yes, XSchema
      and now XForms. Complete bullshit, really.


      Good and important technologies win, even without
      Microsoft's help. This was proven by the W3C
      and its members several times. XForms *isn't* Science Fiction, it is extremely real, just like XSLT, XSchema and XML itself.