3.2. Construction of data from previous slide

Note the X-definition describes a model of the result. The result is created from input data as described in the create section of the script.

<xd:def xmlns:xd="http://www.xdef.org/xdef/4.2" xd:name="GenContract" >
  <Contract ProcessedDate="required; create toString(now(),'yyyy-MM-dd HH:mm');"
      ConractId="required num(10); create from('@num');" >
    <Owner xd:script="occurs 1; create from('Client[@role=\'1\']');" 
        CompanyId="required num(8); create from('@cId');"
        Name     ="required string(1,30); create from('@name');" />
    <Holder xd:script="occurs 1; create from('Client[@role=\'2\']');" 
        PersonalId="required string(10,11); create from('@personalId');"
        Firstname ="required string(1,30); create from('@firstname');"
        Lastname  ="required string(1,30); create from('@lastname');" />
    <Policyholder xd:script="occurs 1; create from('client[@role=\'3\']');"
        CompanyId="required num(8); create from('@cId');"
        Name     ="required string(1,30); create from('@firstname') + ' ' + from('@lastname');"/>
  </Contract>
</xd:def>
Input data:
<Contract num="0123456789">
  <Client role="1" name="Some Company Ltd" cId="12345678" />
  <Client role="2" firstname="John" familyname="Smith" pId="311270/1234" />
  <Client role="3" firstname="Fred" familyname="Brown" personalId="311270/1234" cId="87654321" />
</Contract>
You can try it HERE