Improving the Web Forms Experience (original) (raw)

XForms

Improving the Web Forms Experience

CWI and W3C
Kruislaan 413
1098 SJ Amsterdam
The Netherlands

Steven.Pemberton@cwi.nl
www.cwi.nl/~steven

About the Instructor

Steven Pemberton is a researcher at the CWI, The Centre for Mathematics and Computer Science, a nationally-funded research centre in Amsterdam, The Netherlands, the first non-military Internet site in Europe.

Steven's research is in interaction, and how the underlying software architecture can support the user. At the end of the 80's he built a style-sheet based hypertext system called Views.

Steven has been involved with the World Wide Web since the beginning. He organised two workshops at the first World Wide Web Conference in 1994, chaired the first W3C Style Sheets workshop, and the first W3C Internationalisation workshop. He was a member of the CSS Working Group from its start, and is a long-time member (now chair) of the HTML Working Group, and co-chair of the XForms Working Group. He is co-author of (amongst other things) HTML 4, CSS, XHTML and XForms.

Steven is also Editor-in-Chief of ACM/interactions.

Objectives

HTML Forms, introduced in 1993, were the basis of the e-commerce revolution. After 10 years experience, it has become clear how to improve on them, for the end user, the author, and the owners of the services that the forms are addressing. XForms is a new technology, announced in October 2003, intended to replace HTML Forms.

The advantages of XForms include:

The presenter is one of the authors of the XForms specifications, and is chair of the Forms Working Group that produced the technology.

This tutorial works from a basis of HTML Forms, and introduces XForms step-by-step. It covers essentially all of XForms except some technical details about events, and no more than a passing reference to the use of Schemas.

Emphasis is on how to improve the user experience, and how XForms improves accessibility and device independence, and makes the author’s life easy in producing a better experience.

Plan

Four sections, each with a practical

  1. Introduction, equivalents to HTML
  2. Editing XML
  3. Controlling controls
  4. Wizards and shopping baskets

HTML Forms: a great success!

Searching

Google

Buying

Amazon

Logging in

Yahoo

Configuring hardware

Linksys router

Reading mail

Reading mail

Composing email

Composing email

Etc etc

Problems with HTML Forms

Soundbite: "Javascript accounts for 90% of our headaches in complex forms, and is extremely brittle and unmaintainable."

XForms

The Approach

The essence is to separate what is being returned from how the values are filled in.

Controls

An essential difference with HTML is that XForms controls are_intent-based_ rather than presentation oriented.

Rather than specifying that a control consists of radio buttons, or a menu, XForms specifies for instance that a control selects one item from a list of items. CSS or similar can be used to provide the necessary presentation.

This way the same XForm can be used across different devices without change.

XForms improves the user experience

XForms has been designed to allow much to be checked by the browser, such as

This reduces the need for round trips to the server or for extensive script-based solutions, and improves the user experience by giving immediate feedback on what is being filled in.

It is easier to author and maintain complicated forms

Because XForms uses declarative markup to declare properties of values, and to build relationships between values, it is much easier for the author to create complicated, adaptive forms, and doesn't rely on scripting.

An HTML Form converted to XForms looks pretty much the same, but when you start to build forms that HTML wasn't designed for, XForms becomes much simpler.

It is XML, and it can submit XML

XForms is properly integrated into XML: it is in XML, the data it collects in the form is XML, it can load external XML documents as initial data, and can submit the results as XML.

By including the user in the XML pipeline, it at last means you can have end-to-end XML, right up to the user's desktop.

However, it still supports 'legacy' servers.

XForms is also a part of XHTML2.

It combines existing XML technologies

Rather than reinventing the wheel, XForms uses a number of existing XML technologies, such as

This has a dual benefit:

It integrates into existing data streams

Data can be pre-loaded into a form from external sources.

Existing Schemas can be used.

It integrates with SOAP and XML RPC.

Doesn't require new server infrastructure.

It is device independent

Thanks to the intent-based controls, the same form can be delivered_without change_ to a traditional browser, a PDA, a mobile phone, a voice browser, and even some more exotic emerging clients such as an Instant Messenger.

This greatly eases providing forms to a wide audience, since forms only need to be authored once.

It is internationalized

Thanks to using XML, there are no problems with loading and submitting non-Western data.

It is accessible

XForms has been designed so that it will work equally well with accessible technologies (for instance for blind users) and with traditional visual browsers.

It is royalty-free and unencumbered

Open standard

Wide industry support

Widely implemented

No vendor lock-in!

(If you think this is a good idea, join W3C!)

It supports new use cases

Regular forms uses

Editing XML

Spreadsheets

Applications

As output transformation

Basic structure of XForms

Take this simple HTML form:

Search **** **Find ** **** ****

The main difference in XForms is that details of the values collected and how to submit them are gathered in the head, in an element calledmodel; only the form controls are put in the body.

... basic structure

So in this case the minimum you need in the head is (XForms elements and attributes are in lower case):

The <form> element is now no longer needed; the controls in the body look like this:

Find Go

... basic structure

What you can hopefully work out from this is that form controls have a<label> element as child, the <input>uses "ref" instead of "name", and there is a separate submit control that links to the details of the submission in the head. So the complete example is:

Complete XForms search example

<h:html xmlns:h="http://www.w3.org/1999/xhtml" xmlns="" title="undefined" rel="noopener noreferrer">http://www.w3.org/2002/xforms"> <h:head> <h:title>Search <submission** **action="http://example.com/search"** **method="get" id="s"/> <h:body> <h:p> Find Go

Namespaces

HTML as default namespace

Search **** **** ****

**** **Find** **** **** **Go** ****

Choice of prefixes

Making XForms documents interoperable

FormsPlayer failed to load

XForms equivalents for simple HTML Forms features

Now to compare one for one HTML forms controls with XForms equivalents

Simple Text Input

To input a single text element

First name:

is written

First name:

There is no need to indicate that it is text: in the absence of any other information, by default it is text (called string in XForms).

input

We will see later how to give any control an initial value.

Textarea

To input multiline text

Message:

is written

textarea

Styling controls

Styling is done using a style sheet. For instance:

textarea[ref="message"] { font-family: sans-serif; height: 20em; width: 80em }

or

textarea[ref="message"] { font-family: serif; height: 2cm; width: 20% }

If you want all your textareas to have the same dimensions, you can use

textarea { font-family: sans-serif; height: 20em; width: 80em }

Adding a stylesheet

The easiest way to include a style sheet in your document is to add this at the beginning of the document:

where 'style.css' is the name of your stylesheet, although in XHTML you can also say in the :

(In IE you must do this)

Radio Buttons

Radio buttons select one value from a set:

Gender: Male Female

becomes

Gender: MaleM FemaleF

Presentation of controls

select1

select1 min

We will see later how to preselect a value.

Checkboxes

HTML Checkboxes select zero or more from a list.

Flavors: Vanilla Strawberry Chocolate

is written

... checkboxes

Flavors: Vanillav Strawberrys Chocolatec

select

Depending on the presence of the multiple attribute in HTML, menus select one, or zero or more from a list of options. You either use<select1> to select a single choice, or<select> to select zero or more.

Month:

would be written:

... menus

Month: MarchMar AprilApr MayMay

select compact
If multiple isn't on the HTML select, useselect1 instead.

Open and closed selections

You can add selection="open" on select andselect1 to allow for open ended selections:

Redred ...

File Select

To select a file to be uploaded

... File:

is written

<submission method="form-data-post" .../> ... File:

upload

Passwords

Password:

is written

Password:

secret

Reset

is therefore written

Clear all fields

trigger

Exercise: Log in

Write a form to login somewhere.

Example

If your form doesn't work, check that:

Buttons

Buttons have no predefined behavior, but have a behavior attached to them which is triggered when a relevant event occurs.

The button element

can be written

Show <h:script ev:event="DOMActivate" type="text/javascript">show()

or

... buttons

Show

where "#show" locates the element (for instance ascript element) that implements the behavior: