3.2. XForm Editor Overview

XForm Editor allows an existing XForm document to be edited or a new XForm document to be built from an xml data flux. Moreover, XForm Editor provides the capability of internationalizing XForms by choosing desired languages. To build new XForms, XForm Editor analizes data obtained from a generic xml flux and creates corresponding XForm elements, joining to each one a bind element containing its properties. Inside each element's label is a reference to the corresponding label id, which allows the corresponding label name to be found in the language files.

XML Flux Example:

<process>
  <name>XformEditorDemo</name>
  <Version>1.0</Version>
    <properties>
      <property id="Id">
        <value/>
        <type>input</type>
      </property>
      <property id="ProductName">
        <value/>
        <type>input</type>
      </property>
      <property id="Description">
        <value/>
        <type>input</type>
      </property>
      <property id="Type">
        <value>solid</value>
        <type>select</type>
        <possible-values>
          <possible>solid</possible>
          <possible>liquid</possible>
          <possible>gaz</possible>
        </possible-values>
      </property>
      <property id="Custumer">
        <value>Carrefour</value>
        <type>selectd</type>
        <possible-values>
          <possible>Carrefour</possible>
          <possible>Casino</possible>
        </possible-values>
      </property>
      <property id="stock">
        <value/>
        <type>input</type>
      </property>
  </properties>
</process>

Generated XForm Example:

<html xmlns="http://www.w3.org/2002/06/xhtml2"
     xmlns:xf="http://www.w3.org/2002/xforms"
     xmlns:xsd="http://www.w3.org/2001/XMLSchema"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <head>
        <title>XForm</title>
        <xf:model id="model">
            <xf:instance id="instance" src="contextobject:$instance"/>
            <xf:instance id="lang" src="contextobject:$lang"/>
            <xf:submission action="" id="bValider" method="post" replace="all"/>
            <xf:bind constraint="" id="b Id"
                 nodeset="properties/property[@id='Id']/value"
                 readonly="false()" relevant="true()" required="true()"
                 type="integer"/>
            <xf:bind constraint="" id="b ProductName"
                 nodeset="properties/property[@id='ProductName']/value"
                 readonly="false()" relevant="true()"
                 required="(//properties/property[@id='Type']/value != 'solid')"
                 type="string"/>
            <xf:bind constraint="" id="b Description"
                 nodeset="properties/property[@id='Description']/value"
                 readonly="false()" relevant="true()" required="false()"
                 type="string"/>
            <xf:bind constraint="" id="b Type"
                 nodeset="properties/property[@id='Type']/value"
                 readonly="false()" relevant="true()" required="true()"
                 type="string"/>
            <xf:bind constraint="" id="b Custumer"
                 nodeset="properties/property[@id='Custumer']/value"
                 readonly="false()" relevant="true()" required="true()"
                 type="string"/>
            <xf:bind constraint="" id="b stock"
                 nodeset="properties/property[@id='stock']/value"
                 readonly="false()" relevant="true()" required="false()"
                 type="integer"/>
        </xf:model>
    </head>
    <body>
        <xf:group appearance="full">
            <xf:label id="projectname"
                 ref="instance('lang')/string[@id='XformEditorDemo']"/>
            <xf:input bind="b Id" content="no" extattr="project" id="Id">
                <xf:label
                     ref="instance('lang')/string[@id='Id']"/>
                <xf:alert
                     ref="instance('lang')/string[@id='alert']"/>
            </xf:input>
            <xf:input bind="b ProductName" content="no" extattr="project"
                 id="ProductName">
                <xf:label
                     ref="instance('lang')/string[@id='ProductName']"/>
                <xf:alert
                     ref="instance('lang')/string[@id='alert']"/>
            </xf:input>
            <xf:textarea bind="b Description" content="no" extattr="project"
                 id="Description">
                <xf:label
                     ref="instance('lang')/string[@id='Description']"/>
                <xf:alert
                     ref="instance('lang')/string[@id='alert']"/>
            </xf:textarea>
            <xf:select1 appearance="full" bind="b Type" content="no"
                 extattr="project" id="Type">
                <xf:label
                     ref="instance('lang')/string[@id='Type']"/>
                <xf:alert
                     ref="instance('lang')/string[@id='alert']"/>
                <xf:itemset
                     nodeset="instance('lang')/possible-values[@id='Type']/possible">
                    <xf:label ref="."/>
                    <xf:value ref="@id"/>
                </xf:itemset>
            </xf:select1>
            <xf:select appearance="minimal" bind="b Custumer" content="no"
                 extattr="project" id="Custumer">
                <xf:label
                     ref="instance('lang')/string[@id='Custumer']"/>
                <xf:alert
                     ref="instance('lang')/string[@id='alert']"/>
                <xf:itemset nodeset="../possible-values/possible">
                    <xf:label ref="."/>
                    <xf:value ref="."/>
                </xf:itemset>
            </xf:select>
            <xf:submit submission="bValider">
                <xf:label
                     ref="instance('lang')/string[@id='submit']"/>
            </xf:submit>
            <xf:input bind="b stock" content="no" extattr="project" id="stock">
                <xf:label
                     ref="instance('lang')/string[@id='stock']"/>
                <xf:alert
                     ref="instance('lang')/string[@id='alert']"/>
            </xf:input>
        </xf:group>
    </body>
</html>

Generated Language File (English Example):

<strings>
 <string id="XformEditorDemo">XformEditor Demonstration </string>
 <string id="alert">Error : fill in this field</string>
 <string id="Id">Identifier of the product</string>
 <string id="ProductName">ProductName</string>
 <string id="Description">Description of the product</string>
 <possible-values id="Type">
  <possible id="solid">solid_toto</possible>
  <possible id="liquid">liquid</possible>
  <possible id="gaz">gaz</possible>
</possible-values>
 <string id="Type">Type</string>
 <string id="Custumer">External Custumers </string>
 <string id="stock">Number of products in the stock</string>
 <string id="submit">Submit</string>
</strings>