W3Schools

home HOME

XForms Tutorial
XForms HOME
XForms Intro
XForms Model
XForms Namespace
XForms Example
XForms XPath
XForms Input
XForms Selections
XForms Datatypes
XForms Properties
XForms Actions
XForms Functions

References
XForms Datatypes

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Forum

Helping W3Schools

XForms Model

prev next

The XForms model defines a  template for the data to be collected in a form.


The XForms Framework

The purpose of an HTML form is to collect data. XForms has the same purpose.

With XForms, input data is described in two different parts:

  • The XForm model (to describe the data and the logic)
  • The XForm user interface (to display and input the data)

The XForms model defines what the form is, what data it contains, and what it should do.

The XForms user interface defines the input fields and how they should be displayed. 


The XForms Model

The XForms model is used to describe the data.

The data model is an instance (a template) of an XML document.

The XForms model defines a data model inside a <model> element:

<model>
<instance>
  <person>
    <fname/>
    <lname/>
  </person>
</instance>
<submission id="form1"
action="submit.asp"
method="get"/>
</model>

From the example above, you can see that the XForms model uses an <instance> element to define the XML template for data to be collected, and a <submission> element to describe how to submit the data.

The XForms model does not say anything about the visual part of the form (the user interface).


XForms Namespace

If you are missing the XForms namespace in these examples, or if you don't know what a namespace is, it will be introduced in the next chapter.


The <instance> Element

The XForms model uses an <instance> element to define the data to be collected.

XForms is always collecting data for an XML document. The <instance> element in the XForms model defines the XML document.

In the example above the "data instance" (the XML document) the form is collecting data for looks like this:

<person>
  <fname/>
  <lname/>
</person>

After collecting the data, the XML document might look like this:

<person>
  <fname>John</fname>
  <lname>Smith</lname>
</person>


The <submission> Element

The XForms model uses  a <submission> element to describe how to submit the data.

The <submission> element defines a form and how it should be submitted. In the example above, the id="form1" attribute identifies the form, the action="submit.asp" attribute defines the URL to where the form should be submitted, and the method="get" attribute defines the method to use when submitting the data.


The XForms User Interface

The XForms user interface is used to display and input the data.

The user interface elements of XForms are called controls (or input controls):

<input ref="fname"><label>First Name</label></input>
<input ref="lname"><label>Last Name</label></input>
<submit submission="form1"><label>Submit</label></submit>

In the example above the two <input> elements define two input fields. The ref="fname" and ref="lname" attributes point to the <fname> and <lname> elements in the XForms model.

The <submit> element has a submission="form1" attribute which refers to the <submission> element in the XForms model. A submit element is usually displayed as a button.

Notice the <label> elements in the example. With XForms every input control element has a required <label> element.


You'll Need A Container

XForms is not designed to work alone. There is no such thing as an XForms document.

XForms has to run inside another XML document. It could run inside XHTML 1.0, and it will run inside XHTML 2.0.


All Together Now

If we put it all together the document will look like this:

<xforms>
<model>
<instance>
  <person>
    <fname/>
    <lname/>
  </person>
</instance>
<submission id="form1"
action="submit.asp"
method="get"/>
</model>
<input ref="fname"><label>First Name</label></input>
<input ref="lname"><label>Last Name</label></input>
<submit submission="form1"><label>Submit</label></submit>
</xforms>

And the page will display pretty much like this:

First Name
Last Name
  
 


The XForms Processor

An XForms Processor built into the browser will be responsible for submitting the XForms data to a target.

The data can be submitted as XML and could look something like this:

<person>
  <fname>Hege</fname>
  <lname>Refsnes</lname>
</person>

Or it can be submitted as text, looking something like this:

fname=Hege;lname=Refsnes


prev next


Altova® XMLSpy® - The world's best-selling XML editor!

Whether you're new to XML or already an advanced user, the user-friendly views and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to meet your XML and Web services development needs from start to finish.

  • XML editor
  • Graphical XML Schema / DTD editors
  • XSLT 1.0/2.0 editor, debugger, profiler
  • XQuery editor, debugger, profiler
  • Support for Office Open XML (OOXML)
  • Graphical WSDL editor & SOAP debugger
  • Java, C#, C++ code generation
  • And much more!

Download a free 30-day trial today!

Click to see a demo!

Learn what’s new in v2008




diploma   

Get Your Diploma!

W3Schools' Online Certification Program is the perfect solution for busy professionals who need to balance work, family, and career building.

The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.

The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.



Jump to: Top of Page or HOME or Printer Friendly Printer friendly page

W3Schools provides material for training only. We do not warrant the correctness of its contents. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2008 by Refsnes Data. All Rights Reserved.

Validate Validate W3C-WAI level A conformance icon W3Schools was converted to XHTML in December 1999
SITE SEARCH
 
About W3Schools
W3Schools Forum
Web charting
Web based charting
for ASP.NET
WEB HOSTING
$15 Domain Name
Registration
Save $20 / year!
UK Domain Names
UK Web Hosting

Alojamiento Web
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
Domain Name Registration
PHP MySQL Hosting
Top 10 Web Hosting
Web Hosting Providers
Web Hosting Company
UK Reseller Hosting
Web Hosting
WEB BUILDING
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Ecommerce Software
XMLSpy XML Editor
Azbuz Blog
SHOPPING
UK Wholesalers
UK Wholesale
UAE Dubai Property
Private Student Loans
UK Dropshippers & Wholesalers Directory
EDUCATION
US Web Design Schools
HTML Exam
YELLOW PAGES
www.nettkatalogen.no
www.gulex.dk
www.gulex.se
www.gelbex.de
www.teloos.fi
www.teloos.fr
www.teloos.co.uk
www.teloos.at
www.teloos.de