Docstoc

XForms

Document Sample
XForms Powered By Docstoc
					XForms
                        What is XForms?

• XForms is the next generation and successor of HTML forms.

• XForms separate Data from the presentation.

• XForms uses XML to define form data as well as store and transport
data.

• XForms is device independent.

•XForms contains features like calculations and validations of
forms
In Xforms framework, input data is described in two parts:

• The XForm model - defines what the form is, what it should do, what data it
contains
• The XForm user interface - defines the input fields and how they should be
displayed

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

<input ref="fname"><label>First Name</label></input>                   Xform user
<input ref="lname"><label>Last Name</label></input>                     interface
<submit submission="form1"><label>Submit</label></submit>
</xforms>
                    Xform 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.
                                 XForms Namespace
If you want to use XForms in HTML (or XHTML 1.0), you should declare all XForms
elements with an XForms namespace.
XForms is expected to be a standard part of XHTML 2.0, eliminating the need for the
XForms namespace.

<html xmlns:xf="http://www.w3.org/2002/xforms">
<head>
 <xf:model>
  <xf:instance>
   <person>
    <fname/>
    <lname/>
   </person>
  </xf:instance>
  <xf:submission id="form1" method="get" action="submit.asp"/>
 </xf:model>
</head>

<body>
<xf:input ref="fname"><xf:label>First Name</xf:label></xf:input><br />
<xf:input ref="lname"><xf:label>Last Name</xf:label></xf:input><br /><br />
<xf:submit submission="form1"><xf:label>Submit</xf:label></xf:submit>
</body>
</html>
                              XForms and XPath

<input ref="/person/name/fname"><label>First Name</label></input>
<input ref="/person/name/lname"><label>Last Name</label></input>

Binding Using Bind
<model>
 <instance>
  <person>
   <name>
    <fname/>
    <lname/>
   </name>
  </person>
 </instance>
 <bind nodeset="/person/name/fname" id="firstname"/>
 <bind nodeset="/person/name/lname" id="lastname"/>
</model>
The XForms user interface can bind <input> elements using the bind attribute:
<input bind="firstname"><label>First Name</label></input>
<input bind="lastname"><label>Last Name</label></input>
                         XForms Input Controls
• The Input Control

• The <label> Element

• The Secret Control

• The Textarea Control

• The Submit Control

• The Trigger Control

• The Output Control

• The Upload Control
                        XForms Selection Controls


• The Select1 Control

• The Select Control

• The Range Control
                             Xforms data types
<html
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xf:instance>
 <person xmlns="">
  <fname xsi:type="xsd:string"/>
  <lname xsi:type="xsd:string"/>
  <born xsi:type="xsd:date"/>
  <size xsi:type="xsd:integer"/>
 </person>
</xf:instance>

XForms supports all XML Schema data types, except:
Duration                    ENTITY
ENTITIES                    NOTATION


Binding data types :

<xf:bind nodeset="/person/size" type="xsd:integer"/>
                        XForms Properties

<model>
 <instance>
  <person>
   <fname/>
   <lname/>
  </person>
 </instance>
 <bind nodeset="person/lname" required="true()"/>
</model>

XForms Properties :

Required
Calculate
Readonly
Relevant
Type
Constraint
                 XForms Actions
Message Element
<input ref="fname">
 <label>First Name</label>
 <message level="ephemeral" event="DOMFocusIn">
 Input Your First Name
 </message>
</input>

Setvalue Element
<input ref="size">
 <label>Size</label>
 <setvalue value="50" event="xforms-ready"/>
</input>

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:7
posted:11/15/2011
language:English
pages:11