Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5. XForms Model Properties > Property calculate for Dynamic Computation

5.8. Property calculate for Dynamic Computation

We saw an example of model property calculate in the shopping cart example in Section 4.3.3. The value of property calculate is an XPath expression that computes the value to be stored in the node to which the calculate property applies. Thus, when an instance node has model property calculate applied to it, it does not make sense to bind an XForms input control to that node. The XForms processor will automatically update the value of nodes having property calculate by evaluating the XPath expression provided after first updating the value of dependent nodes.

5.8.1. Examples of Property calculate

XPath expressions for property calculate can be cumbersome to write for a first-time XPath user. The advantage with using XPath as the expression language for this purpose is that XPath is side-effect free. Thus, even though XPath may appear cumbersome at first flush when compared to full-blown programming languages like Javascript, the decision to use XPath within XForms is a conscious one. A consequence of XPath expressions being side-effect free is that complex XForms become easier to debug since the calculate property on a node can affect only the value of that particular node.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint