XHTML2 & XForms (original) (raw)

About me

Researcher at the Dutch national research centre CWI (first European Internet site)

Co-designed the programming language ABC, that was later used as the basis for Python

In the late 80's designed and built a browser, with extensible markup, stylesheets, vector graphics, client-side scripting, etc. Ran on Mac, Unix, Atari ST

Organised 2 workshops at the first Web conference in 1994

Co-author of HTML4, CSS, XHTML, XML Events, XForms, etc

Chair of W3C HTML and Forms working groups

Until recently Editor-in-Chief of ACM/interactions.

XHTML2: The next generation in the X/HTML family

In designing XHTML2, a number of design aims were kept in mind to help direct the design. These included:

As generic XML as possible: if a facility exists in XML, try to use that rather than duplicating it. This means that it largely already works in existing browsers (main missing functionality XForms and XML Events).

Less presentation, more structure: use stylesheets for defining presentation.

More usability: within the constraints of XML, try to make the language easy to write, and make the resulting documents easy to use.

More accessibility: 'designing for our future selves' – the design should be as inclusive as possible.

XHTML2 (more)

Better internationalization.

More device independence: new devices coming online, such as telephones, PDAs, tablets, televisions and so on mean that it is imperative to have a design that allows you to author once and render in different ways on different devices, rather than authoring new versions of the document for each type of device.

Better forms: after a decade of experience, we now know how to make forms a better experience.

Less scripting: achieving functionality through scripting is difficult for the author and restricts the type of user agent you can use to view the document. We have tried to identify current typical usage, and include those usages in markup.

Better semantics: integrate XHTML into the Semantic Web.

Try to please as many people at once

Keep old communities happy

Keep new communities happy

Backwards compatibility

Earlier versions of HTML claimed to be backwards compatible with previous versions. For instance, HTML4

<meta name="author" content="Steven Pemberton">

puts the content in an attribute and not in the content of the element for this reason.

In fact, the only version of HTML that is in any sense backwards compatible is XHTML1 (others all added new functionality like forms and tables).

XHTML2 takes advantage of CSS not to be element-wise backwards compatible, but architecturally backwards compatible.

For instance, as mentioned already, much of XHTML2 works already in existing browsers.

A Simple Example

XHTML2 is recognisably a family member:

Virtual Library

Moved to example.org.

Structure and Presentation

Remove all presentation-oriented elements

Add more structuring elements

Use CSS for all presentation

Butterfly

Post

focus

gemination

party

Bodysnatchers

worm

Structure

One of the biggest problems for non-sighted people with many HTML pages is working out what the structure is. Often the only clue is the level of header used (h1, h2 etc), and often they are not used correctly.

To address this, in XHTML2 you can now make the structure of your documents more explicit, with the

and elements.

A heading ...
A lower-level heading ...

Structuring advantages

Advantages include:

h1-h6 are currently still available.


It is amazing how little issues can take so much effort.

A question that we often had to address was "is


presentational?"

The Japanese community were also asking for a .

And then we had an aha moment...

James Joyce Ulysses

James Joyce Ulysses <hr>

James Joyce Ulysses

James Joyce Ulysses <hr>

James Joyce Ulysses

James Joyce Ulysses <hr>

Separator

These are all


s!
is not presentational, but structural: a lightweight section separator.

The only thing wrong with


is that it is not (necessarily) horizontal, and not (necessarily) a rule!

We already needed a separator element for navigation lists, so we just decided to do away with all the confusion and rename


to .

Better paragraphs

A paragraph is now much closer to what people perceive as a paragraph. For instance, this is now allowed:

Advantages include:

Images

You might be surprised to know that was not in the original HTML.

is actually badly designed:

... images

So what we have done is allowed the src attribute on any element. The image replaces the element content, and the element content is fallback. Essentially we have added fallback, moved the longdesc into the document, merged it with alt, and allowed it to be marked up all in one go.

Walk down the steps from the platform turn left, and walk on to the end of the street

The element is still available, but the alt text goes in the content:

W3C

Image types

HTML4 has the 'type' attribute in a number of places as a hint to the browser as to what it could expect if it went and got a resource.

But it is pretty useless. Some browsers ignore it, some don't.

Now it is a specification of the type, and meshes with the HTTP accept: field. This means that

...

will give you a GIF, or otherwise give you the fallback.

Similarly, you can write:

...

...

Leaving the type attribute off is equivalent to sayingtype="*/*"

Whitespace and pre

In HTML the only method to retain whitespace in content is with<pre>.

IN XHTML2, all elements can use the attributelayout="relevant".

...

This doesn't impose a fixed-width font on the output, just that spaces and newlines are preserved.

Lines


splits a paragraph into different parts, but they are unaddressable with CSS. So instead of a breaking element, XHTML2 uses a structuring element:

Steven Pemberton
CWI/W3C
Amsterdam

is now

Steven Pemberton CWI/W3C Amsterdam

This gives you many more presentational possibilities, such as automatic numbering of lines, or colouring of alternate lines, etc.

Hypertext

In a non-backwards compatible step, HTML4 allowed any element to become the target of a link (with id on any element).

XHTML2 extends this by now allowing any element to become the source of a link as well, by allowing href anywhere.

So, instead of

  • W3C
  • you may now write

  • W3C
  • though is still available.

    One thing you see everywhere on the web are menus for navigation, implemented with script.

    XHTML2 now supports these natively:

    Go
  • Home
  • Technical reports
  • ...

    Whether they are presented as menus, or in some other way, depends on the platform, the stylesheet, etc.

    dir, edit

    Certain things that used to be done with elements are now done with attributes:

    and

    <span **dir="rlo"**>...

    media

    In certain places in HTML4/XHTML1 you can say that an element applies only to a specific media, like:

    <**/head**> <**group** compose="vertical"> <**frame** id="banner" source="banner.xhtml"/> <**group** compose="horizontal"> <**/group**> <**frame** id="footer" source="copyright.xhtml"/> <**/group**>

    home.xframes#frames(main=a.xhtml,banner=b.xhtml)

    XForms: the new Web Forms language

    The major new functionality in XHTML2 is the forms language, XForms.

    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

    So why XForms?

    After a decade of experience with HTML Forms, we now know more about what we need and how to achieve it.

    Problems with HTML Forms

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

    XForms, the Approach and the Advantages

    XForms has been designed based on an analysis of HTML Forms, what they can do, and what they can't.

    The Essence: Separation of Values from Controls

    There are two parts to the essence of XForms. The first is to separate what is being returned from how the values are filled in. Separation of values from controls

    The Essence: Intent-based Controls

    The second part is that the form controls, rather than expressing how they should look (radio buttons, menu, etc), express their intent (this control selects one value from a list).

    You then use styling to say how they should be represented, possibly with different styling for different devices (as a menu on a small screen, as radio buttons on a large screen).

    Colour: red green blue

    Overview of Advantages

    XForms gives many advantages over classic HTML Forms:

    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 rather easy to implement

    XMLDOMCSSJavascriptXHTMLXPathXForms

    ��� =Regular XHTML Browser

    Time to build all of above: 3 programmers, 4 months

    Total footprint (on IPAQ implementation): 400K (above Java VM)

    In fact this is quite evolutionary: XForms uses existing W3C components. It is only the XForms processing model that describes when to calculate values that is really new.

    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!)

    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 you put the following in the head (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

    Complete XForms search example

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

    **Find** **Go**

    Making the Submitted Values Explicit

    Although in simple cases the instance element is optional, it is good practice to include an explicit instance, like this:

    ... Search

    Initial Values

    For initialising controls including initialising checked boxes, and selected menu items etc., you just supply an instance with pre-filled values. For the search example:

    **Keywords**

    would pre-fill the text control with the word Keywords.

    **10**

    Getting Initial Values From Elsewhere

    Configuring Hardware

    This makes configuring hardware even easier than it now is: instead of the device hosting a web server that can deal with HTML Forms, all it has to do is deliver its configuration parameters as an XML document, and XForms provides the interface.

    'Editing' any XML document

    ... example

    Editing example

    Suppose a shop has very unpredictable opening hours (perhaps it depends on the weather), and they want to have a Web page that people can go to to see if it is open. Suppose the page in question has a single paragraph in the body:

    The shop is closed today.

    Well, rather than teaching the shop staff how to write HTML to update this, we can make a simple form to edit the pageinstead:

    Editing XHTML page

    ... The shop is now: Open**open** Closed**closed** OK

    XForms controls

    XForms has equivalent controls for everything that you can do in HTML.

    But there is an important difference: XForms controls are not presentation based, but intent-based – they say what they are meant to achieve not how they do it.

    ... controls

    For instance, a select control

    Country Netherlandsnl United Kingdomuk Francefr

    can be represented using radio buttons, a drop-down menu, a select list (or anything else suitable you can think of)

    depending on the style-sheet or the choice of the device.

    Country Netherlands United Kingdom France

    XForms equivalents for simple HTML Forms features

    As already said, XForms has equivalents for all HTML controls, such as text, text boxes, selecting one or many, file upload, etc.

    A user agent may adapt an input control based on knowledge of the data-type involved.

    For instance

    Departure date

    can pop up a date picker control.

    Extra control: range

    XForms has a couple of extra controls:

    may be represented with a slider or similar.

    Extra control: output

    The output control allows you to include values as text in the document.

    Your current total is:

    or

    Total

    This can be used to allow the user to preview values being submitted.

    ... output

    You can also calculate values:

    Total volume:

    (where height, width and depth are values collected by other controls.)

    Wizards: toggle and switch

    These are used to reveal and hide parts of the interface.

    ... Next <**toggle case="inputage"** ev:event="DOMActivate" /> ... ... ...

    An example

    Repeat

    Repeat allows you to bind to repeating items in an instance. There are also facilities to delete and insert items in a repeating set.

    Date ...

    You have already seen an example

    Controlling Controls

    Properties

    The 'model binding' properties that you can control are:

    ... properties

    Note that in XForms it is the collected value that has the property, not the control, but the property shows up on all controls bound to the value.

    These properties use a <bind> element that goes in the<model>. To use bind, you must have an explicit <instance> element.

    Disabled Controls = relevant

    To disable controls you use the relevant property. For instance, to say that the credit card number only needs to be filled in if the person is paying by credit, you can write:

    **** **** **** ****

    An example of what we are going to do

    ... relevant

    ... writing the controls

    The controls could be written like this (but note that there is no indication that they may get disabled: that is inherited from the value they refer to):

    <select1 **ref="method"**> Method of payment: Cashcash Credit cardcredit

    <input **ref="cc/number"**>Card number: <input **ref="cc/expires"**>Expiry date:

    Readonly Controls

    Similarly to relevant, you can specify a condition under which a value is read-only. For instance:

    basic black

    This example says that the default value of color isblack, and can't be changed if variant has the value basic.

    Required Controls

    A useful new feature in XForms is the ability to state that a value must be supplied before the form is submitted.

    The simplest case is just to say that a value is always required. For instance, with the search example:

    ... required

    but like the readonly and relevant attributes, you can use any XPath expression to make a value conditionally required:

    <bind nodeset="state" **required="../country='USA'"**/>

    which says that the value for state is required when the value for country is "USA".

    It is up to the browser to decide how to tell you that a value is required, but it may also allow you to define it in a stylesheet.

    Constraint Property

    This property allows you to add extra constraints to a value. For instance:

    <bind nodeset="year" **constraint=". > 1970"**/>

    constrains the year to be after 1970.

    Note the XPath use of "." to mean "this value".

    Calculate Property

    It is possible to indicate that a value in the instance is calculated from other values. For instance:

    <bind ref="volume" **calculate="../height * ../width * ../depth"**/>

    When a value is calculated like this, it automatically becomesreadonly.

    ... calculate functions

    There are a number of functions available, including:

    Types

    ... types

    ... types

    There are a number of useful built-in types you can use, including:

    ... types

    You can apply Schemas to instances:

    ...

    or include them inline:

    ... ... ...

    Combining Properties

    If you have several binds referring to the same value, you can combine them:

    <bind nodeset="q" **type="xsd:integer"** **required="true()"**/>

    Submitting

    Now to look at details of submission, like multiple submissions, submission methods, and what happens after submission.

    Multiple Submissions

    **** ****

    ... multiple submissions

    and then in the body:

    Find: <submit **submission="org"**> Search example.org <submit **submission="com"**> Search example.com

    Find:

    Submission Methods

    ... submission to file

    Life after Submit

    ... example of different submissions

    ... example

    <**accountnumber/>
    **
    ... Account Number <**submit submission="prefill"**>Find Name <**submit submission="change"**>Submit

    More than one form in a document

    ... more than one form

    <model **id="search"**> <submission id="s" .../> <model **id="login"**> <submission id="l" .../> ... <input **model="search"** ref="q">Find Go ... <input **model="login"** ref="user">User name <secret **model="login"** ref="passwd">Password Log in

    More than one instance in a model

    ... more than one instance

    125 ... ... ... Date

    ... more than one instance

    ...

    Using more than one instance

    Useful for filling itemsets in select and select1:

    ...

    or creating dynamic labels (think multilingual) [example]:

    can also take src="..."

    Implementations

    At release XForms had more implementations announced than any other W3C spec had ever had at that stage

    Different types of implementation:

    Many big players doing implementations, e.g.

    Users

    As you would expect with a new technology, first adopters are within companies and vertical industries that have control over the software environment used.

    ... users

    That list is there just to give a taste, but amongst others not mentioned there are at least 3 fortune 500 companies who don't want it to be public knowledge so that their competitors don't get wind of it.

    As more industries adopt XForms, the expectation is that it will then spread out into horizontal use.

    Mobile: XForms (XSmiles) on an IPAQ

    XSmiles now running under J2ME PP

    XSmiles on an Ipaq

    ...

    Japanese phones

    ...

    Japanese phone architecture, showing use of XForms

    XForms (picoForms) on a Nokia 9300

    XForms running on a Nokia 9300

    XForms (SolidApp) on a Sony Ericsson phone

    XForms on a mobile phone

    XForms for Web Applications

    XForms has everything needed for an application:

    People are already using XForms for some pretty exciting applications. xport.net who produce FormsPlayer are doing the most interesting stuff, by using SVG as the stylesheet language. They have produced examples such as a world clock, a contacts database, and even Google Maps in XForms!

    world clock in XForms

    Google maps in XForms

    Google maps in XForms

    maps

    The interesting thing about this last example is that it is 25K of XForms, compared with 200K+ of javascript...

    This is largely thanks to the declarative programming model of XForms, that means that you don't have to deal with lots of the fiddly administrative details.

    Bear in mind that empirical evidence suggests that a program that is an order of magnitude larger takes 34 times as much effort; or put the other way, a program that is an order of magnitude smaller costs 3% of the effort...

    This has been backed up recently by a company using XForms for designing special-purpose interfaces. Usually it takes 30 people 5 years to finish one project. With XForms it took 10 people 1 year (including learning XForms).

    Conclusion (XForms)

    XForms is achieving critical mass much faster than we had anticipated. Companies large and small, consortia, even governments and government agencies are beating a path to our door.

    Apart from offering a far more managable base for forms on the web, we believe that XForms is an excellent basis for future web applications, because it offers a model that gives you:

    Conclusion (XHTML2)

    XHTML2 has been designed on the basis of requirements from a large number of different communities.

    It has been designed to be as recognisably XHTML as possible within the constraints of the new requirements.

    It is going to last call shortly: we welcome your comments!