In the previous article, I showed you how to manage user input in the XForms model. I discussed the process of submitting an XForm and – more importantly - validating user input prior to submission using built-in XML Schema support. In this concluding article, find out how to use the <xforms:bind> element to perform calculations on form input values, integrate XPath expressions into your XForms model and get a crash course in the XForms event model.
And that's about all I have for you. Over the course of this three-part tutorial, I introduced you to the new XForms 1.0 specification, and showed you how to create a data model and bind its elements to form input controls. I also explained the various XForms input controls, and showed you how they map into the standard HTML form controls.
Next, I discussed the process of submitting an XForm, with a look at the <xforms:submission> element and the "submit" input control. I also showed you how to perform primitive datatype validation in an XForm using built-in XML Schema datatypes, and how to extend this to perform more complex validation by integrating your own custom datatypes into the XForms model.
Finally, in this concluding part, I introducing the concept of binding using the <xforms:bind> element, which allows you to disable or enable input controls, mark them as read-only, enforce special constraints on your input controls, and even calculate values on the fly - tasks which earlier required complex JavaScript, but are now as simple as combining XPath expressions. I also looked at some XPath functions, and showed you how you can use them within your binding expressions for greater flexibility in calculations. I wrapped things up with a brief introduction to the XForms event model - this is a fairly complex topic, and one which requires in-depth understanding of the XML Events specification as well, so if you'd like to learn more about it, be prepared to spend some time on research (with the specification in hand).
I hope you enjoyed this article, and that it gave you sufficient grounding to get you started with XForms. XForms is one of the more interesting emerging XML technologies, and you can expect to see it grow more powerful in subsequent iterations. So go on - it's time to practice!
Note: Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article.