Logo         Community
The Company
Your Account
Contact Us
XForms Basics (part 3)
Perform calculations on form input values and get a crash course in the XForms event model.

| Operating With Extreme Caution |

You've already seen how various XML technologies integrate seamlessly with each other when it comes to XForms. In fact, in the last part of this tutorial, I showed you how to re-use an XML Schema datatype definition in an XForms model, and how to use XPath expressions to reference and bind instance data with the XForms user interface. But why stop there? You can also use logical, comparison and arithmetic operators and functions with XPath expressions, in order to perform calculations using the instance data in an XForms model.

In order to do this, you need to first understand the <xforms:bind> element, which makes it possible to bind instance data elements to specific properties and constraints. The <xforms:bind> element comes with a number of additional attributes, which can be used to specify whether a particular element of the instance data is required, read-only, constrained to specific values or compliant with a specific type.

Consider the following example, which demonstrates:

<!-- form model -->
<xforms:model id="account">
<name />
<number />
<xforms:bind id="accountNumberRequired" nodeset="/account/number" required="true()" />

In this case, the bind definition states that the account number is required in order for the form to be submitted. This is a very fundamental example of input validation. With normal HTML forms, you'd need to write client-side and server-side code to manage this requirement; with XForms, it comes built-in!

In case you were wondering where this bind definition gets used, the XForms specification states that user interface elements can then be linked to the definition, simply by adding a "bind" attribute to the interface control (instead of the traditional "ref" attribute). Here's an example:

<!-- define the form interface -->
<xforms:input bind="accountNumberRequired">
<xforms:label>Account number</xforms:label>

How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!

previous page more like this  print this article  next page
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback