Home arrow XML arrow Page 5 - XForms Basics

Welcome to Nowhere - XML

XMLToday, XML is most definitely in the mainstream, and proving its mettle by making all kinds of new and unique applications possible (witness the success of Amazon.com's AWS service, or the Google APIs, both based on XML technology). This article provides an introduction to XForms, a recent W3C Recommendation that suggests using XML to manage the display, input and processing of form data on the Web.

TABLE OF CONTENTS:
  1. XForms Basics
  2. Out with the Old...
  3. ... In With the New
  4. What's In A Name?
  5. Welcome to Nowhere
  6. A Tour of Nowhere
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 41
January 12, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

The previous example demonstrated two of the form controls available in XForms. However, there are lots more. Here's a brief list:

  1. <xforms:input>     
    A single-line text entry field.
  2. <xforms:secret>    
    A single-line text entry field which masks user input, good for passwords.
  3. <xforms:select>    
    A list field allowing multiple selection.
  4. <xforms:select1>   
    A list field allowing selection of only a single item from the list.
  5. <xforms:textarea>  
    A multi-line text entry field
  6. <xforms:upload>    
    A file upload field.
  7. <xforms:range>     
    A field which restricts entry to a range of values.
  8. <xforms:submit>    
    A form submission field.
  9. <xforms:output>    
    A field for displaying values from the instance data.

In addition, the XForms specification also defines the following elements which may be attached to the controls above:

  1. <xforms:label>     
    Descriptive information for the corresponding control.
  2. <xforms:help>      
    Help information for the corresponding control.
  3. <xforms:hint>      
    Brief usage information for the corresponding control.

Here's an example demonstrating some of them in action:


<html xmlns=http://www.w3.org/1999/xhtml
xmlns:xforms="http://www.w3.org/2002/xforms/cr">
 
<
head>
 
<!-- 
form model -->
<
xforms:model id="immigration">
 <
xforms:instance src="immigration.xml" />
</
xforms:model>
<
basefont face="Arial">
 
</
head>
 
<
body>
 
<!-- 
define interface controls -->
<
table cellspacing="5" cellpadding="5" 
border="0">
<
tr>
<
td colspan="2" align="center">
<
font color="red" size="4">
Welcome to Immigration
</font></td>
</
tr>
 
<
tr>
<
td>
 <
xforms:input id="txtname" model="immigration" 
ref="/immigrant/name">
  <
xforms:label>Name</xforms:label>
  <
xforms:hint>
  
Enter your name here
  
</xforms:hint>
 </
xforms:input>
</
td>
</
tr>
 
<
tr>
<
td>
 <
xforms:input id="txtcitizenship" model="immigration"
ref="/immigrant/citizenship">
  <
xforms:label>Citizenship</xforms:label>
  <
xforms:hint>
  
Enter your country of origin here
  
</xforms:hint>
 </
xforms:input>
</
td>
 
</
tr>
<
tr>
<
td align="left">
 <
xforms:select1 model="immigration" 
 
ref="/immigrant/purpose" appearance="full">
  <
xforms:label>Purpose of visit</xforms:label>
  <
xforms:hint>
  
Please state the purpose of your visit
  
</xforms:hint>
  <
xforms:item>
   <
xforms:label>Business</xforms:label>
   <
xforms:value>B</xforms:value>
  </
xforms:item>
  <
xforms:item>
   <
xforms:label>Pleasure</xforms:label>
   <
xforms:value>P</xforms:value>
  </
xforms:item>
  <
xforms:item>
   <
xforms:label>Other</xforms:label>
   <
xforms:value>O</xforms:value>
  </
xforms:item>
 </
xforms:select1>
</
td>
</
tr>
 
<
tr>
<
td align="left">
 <
xforms:select model="immigration" 
 
ref="/immigrant/immunization" appearance="full">
  <
xforms:label>Immunization</xforms:label>
  <
xforms:hint>
  
Please select the diseases that 
  you have been immunized against
  
</xforms:hint>
  <
xforms:item>
   <
xforms:label>Smallpox</xforms:label>
   <
xforms:value>100</xforms:value>
  </
xforms:item>
  <
xforms:item>
   <
xforms:label>Malaria</xforms:label>
   <
xforms:value>113</xforms:value>
  </
xforms:item>
  <
xforms:item>
   <
xforms:label>Yellow fever</xforms:label>
   <
xforms:value>56</xforms:value>
  </
xforms:item>
  <
xforms:item>
   <
xforms:label>Typhoid</xforms:label>
   <
xforms:value>174</xforms:value>
  </
xforms:item>
 </
xforms:select>
</
tr>
 
<
tr>
<
td align="left">
 <
xforms:textarea model="immigration" 
 
ref="/immigrant/address">
  <
xforms:label>
  
Address in home country
  
</xforms:label>
 </
xforms:textarea>
</
td>
</
tr>
</
table>
 
</
body>
</
html>



 
 
>>> More XML Articles          >>> More By Harish Kamath, (c) Melonfire
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

XML ARTICLES

- Google Docs and Xpath Data Functions
- Flex Array Collection Sort and Filtering
- The Flex Tree Control
- Flex List Controls
- Working with Flex and Datagrids
- How to Set Up Podcasting and Vodcasting
- Creating an RSS Reader Application
- Building an RSS File
- An Introduction to XUL Part 6
- An Introduction to XUL Part 5
- An Introduction to XUL Part 4
- An Introduction to XUL Part 3
- An Introduction to XUL Part 2
- An Introduction to XUL Part 1
- XML Matters: Practical XML Data Design and M...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: