Simplified and Canonical Form of XForms PO example

SIMPLIFIED:

<repeat name="row">
    <select1 name="Product"> ...
    <input name="Quantity"> ...
    <input name="Price"> ...
    <output name="LineTotal" calculate="$Price * $Quantity"/>
</repeat>
<output name="Subtotal" calculate="sum($LineTotal)"/>
<output name="Tax" calculate="$Subtotal * 0.07"/>
<output name="Total" calculate="$Subtotal + $Tax"/>

CANONICAL FORM:

<model>
  <instance>
    <data>
      <row>
         <Product>...
         <Price>...
         <Quantity>...
         <LineTotal>...
      </row>
      <row>
         <Product>...
         <Price>...
         <Quantity>...
         <LineTotal>...
      </row>
      <Subtotal>...
      <Tax>...
      <LineTotal>...
    </data>
  </instance>
 
  <bind id="row" nodeset="row">
    <bind id="Product" nodeset="Product"/>
    <bind id="Price" nodeset="Price"/>
    <bind id="Quantity" nodeset="Quantity"/>
    <bind id="LineTotal" nodeset="LineTotal" calculate="$Price * 
$Quantity/>
  </bind>
  <bind id="Subtotal" nodeset="Subtotal" calculate="sum($LineTotal)"/>
  <bind id="Tax" nodeset="Tax" calculate="$Subtotal * 0.07"/> 
  <bind id="Total" nodeset="Total" calculate="$Subtotal + $Tax"/>
</model>

<repeat bind="row">
    <select1 bind="Product"> ...
    <input bind="Quantity"> ...
    <input bind="Price"> ...
    <output bind="LineTotal" calculate="$Price * $Quantity"/>
</repeat>
<output bind="Subtotal"/>
<output bind="Tax"/>
<output bind="Total"/>

John M. Boyer, Ph.D.
Senior Technical Staff Member
Lotus Forms Architect and Researcher
Chair, W3C Forms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@ca.ibm.com 

Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed: 
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw

Received on Wednesday, 12 March 2008 15:43:33 UTC