topical media & game development

talk show tell print

basic-xml-19-ModelItemPropertiesExample.htm / htm



  <?xml version="1.0"?>
  <html 
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:xforms="http://www.w3.org/2002/xforms"
   xmlns:xmml="http://www.XMML.com/namespace" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
  <head>
    <object id="FormsPlayer" classid="CLSID:4D0ABA11-C5F0-4478-991A-375C4B648F58">
    <b>FormsPlayer has failed to load! Please check your installation.</b>
    <br />
   </object>
   <?import namespace="xforms" implementation="#FormsPlayer"?>
   <title>Example using Model Item Properties.</title>
   
   <xforms:model id="default">
    <xforms:instance >
     <xmml:Employee xmlns:xmml="http://www.XMML.com/namespace" >
      <xmml:FirstName></xmml:FirstName>
      <xmml:LastName></xmml:LastName>
      <xmml:Gender></xmml:Gender>
      <xmml:StartDate></xmml:StartDate>
      <xmml:EndDate></xmml:EndDate>
      <xmml:Comments></xmml:Comments>
      <xmml:MaternityLeave></xmml:MaternityLeave>
     </xmml:Employee>
    </xforms:instance>
    <xforms:submission id="mySubmit" action="file://c:/BXML/Ch19/EmployeeData.xml" method="put" />
    <xforms:bind nodeset="/xmml:Employee/xmml:FirstName" required="true()" />
    <xforms:bind nodeset="/xmml:Employee/xmml:LastName" required="true()" />
    <xforms:bind nodeset="/xmml:Employee/xmml:StartDate" required="true()" type="xsd:date" />
    <xforms:bind nodeset="/xmml:Employee/xmml:EndDate" type="xsd:date" required="false()" />
    <xforms:bind nodeset="/xmml:Employee/xmml:MaternityLeave" relevant="/xmml:Employee/xmml:Gender/text() = 'Female'" />
   </xforms:model>
  
   <xforms:model id="myEmployeeInfo">
    <xforms:instance>
     <xmml:EmployeeChoices xmlns:xmml="http://www.XMML.com/namespace" >
      <xmml:GenderChoices >
       <xmml:GenderChoice>
        <xmml:Description>Male</xmml:Description>
       </xmml:GenderChoice>
       <xmml:GenderChoice>
        <xmml:Description>Female</xmml:Description>
       </xmml:GenderChoice>
      </xmml:GenderChoices>
       <xmml:MaternityChoices >
       <xmml:MaternityChoice>
        <xmml:Description>Yes</xmml:Description>
       </xmml:MaternityChoice>
       <xmml:MaternityChoice>
        <xmml:Description>No</xmml:Description>
       </xmml:MaternityChoice>
      </xmml:MaternityChoices>
     </xmml:EmployeeChoices>
    </xforms:instance>
   </xforms:model>
   
  </head>
  <body>
  <p>Enter employee information here.</p>
  <xforms:input model="default" ref="/xmml:Employee/xmml:FirstName" >
   <xforms:label>First Name:</xforms:label>
  </xforms:input>
  <br />
  <xforms:input model="default" ref="/xmml:Employee/xmml:LastName" >
   <xforms:label>Last Name: </xforms:label>
  </xforms:input>
  <br />
  <xforms:select1 model="default" ref="/xmml:Employee/xmml:Gender" >
  <xforms:label>Enter the employee's gender: </xforms:label>
   <xforms:itemset model="myEmployeeInfo" nodeset="/xmml:EmployeeChoices/xmml:GenderChoices/xmml:GenderChoice" >
    <xforms:label ref="xmml:Description" />
    <xforms:value ref="xmml:Description" />
   </xforms:itemset>
  </xforms:select1>
  <p>Enter start and end dates of employment.</p>
  <xforms:input ref="/xmml:Employee/xmml:StartDate">
   <xforms:label>Start Date:</xforms:label>
  </xforms:input>
  <br />
  <xforms:input ref="/xmml:Employee/xmml:EndDate">
   <xforms:label>End Date:  </xforms:label>
  </xforms:input>
  <br />
  <xforms:select1 model="default" ref="/xmml:Employee/xmml:MaternityLeave">
  <xforms:label>Has the employee had maternity leave?</xforms:label>
   <xforms:itemset model="myEmployeeInfo" nodeset="/xmml:EmployeeChoices/xmml:MaternityChoices/xmml:MaternityChoice" >
    <xforms:label ref="xmml:Description" />
    <xforms:value ref="xmml:Description" />
   </xforms:itemset>
  </xforms:select1>
  <br />
  <xforms:textarea ref="/xmml:Employee/xmml:Comments">
   <xforms:label>Enter comments here:</xforms:label>
  </xforms:textarea>
  
  <br />
  <xforms:submit submission="mySubmit">
   <xforms:label>Click Here to submit your Order.</xforms:label>
  </xforms:submit>
  </body>
  </html>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.