XML
  Home arrow XML arrow Page 4 - XForms Basics, Part 2
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

XForms Basics, Part 2
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 8
    2004-01-14


    Table of Contents:
  • XForms Basics, Part 2
  • Welcome to Immigration
  • Data Overload
  • A Custom Job
  • Not My Type
  • The Number Game

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    XForms Basics, Part 2 - A Custom Job
    ( Page 4 of 6 )

    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>
    xmlns:xforms="http://www.w3.org/2002/xforms/cr">
    <head>
    <!-- 
    form model -->
    <xforms:model id="information">
     
    <xforms:instance>
      
    <user>
       
    <name />
       
    <email />
       
    <age />
      
    </user>
     
    </xforms:instance>
     
    <xforms:submission id="submit" 
      ref
    ="/user/name" action="/tmp/user.xml" 
      method
    ="put" indent="yes" 
      omit
    -xml-declaration="no" />
     
    </xforms:model>
    <basefont face="Arial">
    </
    head>
    <
    body>
    <!-- 
    define interface controls -->
    <table cellspacing="5" cellpadding="5" 
      border
    ="0">
    <tr>
    <td>
     
    <xforms:input id="txtname" 
      model
    ="information" ref="/user/name">
      
    <xforms:label>Name</xforms:label>
      
    <xforms:hint>Enter your name 
                        here
    </xforms:hint>
     
    </xforms:input>
    </td>
    </tr>
    <
    tr>
    <td>
     
    <xforms:input id="txtemail" 
       model
    ="information" ref="/user/email">
      
    <xforms:label>Email address
      
    </xforms:label>
      
    <xforms:hint>Enter your email address 
                        here
    </xforms:hint>
     
    </xforms:input>
    </td>
    <
    td>
     
    <xforms:input id="txtage" 
      
    model="information" ref="/user/age">
      
    <xforms:label>Age</xforms:label>
      
    <xforms:hint>Enter your age 
                        here
    </xforms:hint>
     
    </xforms:input>
    </td>
    </
    table>
    <
    xforms:submit submission="submit">
     
    <xforms:label>Save</xforms:label>
     
    <xforms:hint>Save the information 
     entered above to a local file
    </xforms:hint>
    </xforms:submit>
    </
    body>
    </html>

    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:

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

    <name>Harish</name>
    [/output]

    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
     

       

    XML ARTICLES

    - 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...
    - Practical XML Data Design and Manipulation f...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT