Home arrow XML arrow Page 4 - XForms Basics, Part 2

A Custom Job - XML

In the first part of this series, I gave you a quick introduction to the newly-released XForms 1.0 specification, by explaining the fundamental concepts of the XForms model. Now that you know the basics, find out how to submit XForms data to a server-side script or save it to a local client file, and also read about how XForms can integrate with XML Schemas to simplify input validation.

  1. XForms Basics, Part 2
  2. Welcome to Immigration
  3. Data Overload
  4. A Custom Job
  5. Not My Type
  6. The Number Game
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 8
January 14, 2004

print this article



In addition to the attributes you've already seen, the <xforms:submission> element also comes with a bunch of others, which can assist in customizing the manner in which the form data is submitted. Here's a brief list:

ref - Specifies the node to use as root when submitting instance data, defaults to /.

version - Specifies XML version to use when submitting form data.

indent - Toggles indenting of XML data in form submission.

encoding - Specifies XML encoding to use when submitting form data.

omit-xml-declaration - Toggles XML declaration when submitting form data.

standalone - Toggles standalone declaration when submitting form data.

replace - Specifies what to do with the response to the submission.

Consider the following example, which demonstrates some of these in action:

<html xmlns=<A href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</A>
form model -->
<xforms:model id="information">
<name />
<email />
<age />
<xforms:submission id="submit" 
="/user/name" action="/tmp/user.xml" 
="put" indent="yes" 
-xml-declaration="no" />
<basefont face="Arial">
define interface controls -->
<table cellspacing="5" cellpadding="5" 
<xforms:input id="txtname" 
="information" ref="/user/name">
<xforms:hint>Enter your name 
<xforms:input id="txtemail" 
="information" ref="/user/email">
<xforms:label>Email address
<xforms:hint>Enter your email address 
<xforms:input id="txtage" 
model="information" ref="/user/age">
<xforms:hint>Enter your age 
xforms:submit submission="submit">
<xforms:hint>Save the information 
 entered above to a local file

In this case, I've explicitly told the XForms processor to include the XML declaration in the final form submission, but to only include that part of the instance data tree beginning with the element <name>. Here's the output:

<?xml version="1.0" encoding="ISO-8859-1"?>


It's important to note, also, that XForms supports submitting data in more than just PUT and POST methods, and that if you really need to, you can even replicate the behavior of traditional HTML forms by submitting your data in the standard name=value format. The method attribute of the <xforms:submission> element can take any of the values "post", "get", "put", "multipart-post", and "form-data-post." Take a look at the specification to see what each one of these does.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- 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: