xmlForm

Edwin Miguel Triana Arlindo Flavio da Conceicao Alvaro H Mamani-Aliaga

XML Form Specification

In Maritaca, a Form is a XML representation of a questionnaire. It contains the Questionnaire identification and a list of valid questions. This page describes the XML representation for the generated Forms using the Maritaca Form's Editor.

The following basic types and elements of interface are provided:

  • text
  • number
  • radiobutton
  • checklist
  • combobox
  • slide (a number between 0 and 100 percent)
  • date
  • time

In addition, the following advanced itens are deployed:

  • timestamp (an instant of date and time)
  • multimedia
    • picture
    • audio
    • video
  • location
  • temperature
  • movement (level of mobility mensured using the accelerometer)
  • signal (level of signal strengh of wireless connection)
  • luminosity (captured using cameras or luminosity sensors)

XML Form Example

<!--?xml version="1.0" encoding="UTF-8"? -->
<!-- XML Example for Maritaca Project -->

<!-- example of usage of all tags -->
<form>
    <formid>ABC</formid>
    <userid>XYZ</userid>
    <questions>
        <!-- usual tags -->
        <text id="0" next="1" required="true" max="100">
            <help>Enter with name of user.</help>
            <label>Name:</label>
            <default>Fulano</default>
            <if comparison="equal" value="Ciclano" goto="3" />
        </text>

        <number id="1" next="2" required="false" min="0" max="100">
            <help>How old are the user?</help>
            <label>Age:</label>
            <default>0</default>
            <if comparison="equal" value="24" goto="2" />
            <!-- special tag -1, that sends the user to the end of the data gathering 
                (a screen asking if he/she wants to quit, continue, save, or upload data...) -->
            <if comparison="greater" value="100" goto="-1" /> <!-- sorry, you should be dead -->
            <if comparison="less" value="18" goto="-1" /> <!-- forbidden for under 18 -->
            <if comparison="greaterequal" value="10" goto="2" />
            <if comparison="lessequal" value="10" goto="2" />
        </number>

        <radiobutton id="2" required="true">
            <help>Choose the gender declared by the user.</help>
            <label>Sex:</label>
            <default>0</default>
            <items>
                <item>Man</item>
                <item>Woman</item>
                <item>Other</item>
                <item>Not declared</item>
            </items>
            <!-- The index is mapped in numerical values as in a bit representation 
                "Man"=b0001=1, "Woman"=b0010=2, "Other"=b0100=4 -->
            <if comparison="equal" value="1" goto="3" />
            <if comparison="equal" value="4" goto="6" />
        </radiobutton> <!-- returns the string eg., "Woman" -->

        <checkbox id="3" required="false">
            <help>Select the options.</help>
            <label>Do you have eletric/eletronic equipments in home?</label>
            <default>0</default>
            <items>
                <item>Computer</item>
                <item>Cell phone</item>
                <item>Refrigerator</item>
                <item>TV</item>
                <item>DVD player</item>
                <item>Blue-Ray player</item>
                <item>Others</item>
            </items>
            <!-- It uses numerical values as in a bit representation "Computer"=b0001=1, 
                "TV"=b0010=2, and "Computer"+"TV"=b0011=3 -->
            <if comparison="equal" value="1" goto="4" /> <!-- Computer -->
            <if comparison="equal" value="8" goto="5" /> <!-- TV -->
            <if comparison="equal" value="9" goto="6" /> <!-- TV and Computer -->
        </checkbox> <!-- returns the strings in format csv (comma separeted values), eg., "TV,DVD" -->
        <!-- TODO: Editor can not allow commas -->

        <!-- format yyyymmdd -->
        <date id="4" required="false" min="19000101" max="20201231">
            <help>Choose a date</help>
            <label>Choose a date</label>
            <default>19740304</default> <!-- Arlindo's Niver -->
            <if comparison="equal" value="19740304" goto="10" />
            <if comparison="greater" value="19740304" goto="11" />
            <if comparison="less" value="19740304" goto="12" />
            <if comparison="greaterequal" value="19740304" goto="13" />
            <if comparison="lessequal" value="19740304" goto="15" />
        </date>

        <!-- format HH24MMSS -->
        <time id="4" required="false" min="171222" max="210012">
            <help>Choose a hour</help>
            <label>Choose a hour</label>
            <default>120000</default> <!-- Lunch Time! -->
            <if comparison="less" value="050000" goto="12" /> <!-- go back to bed -->
            <if comparison="equal" value="170000" goto="13" /> <!-- tea time -->
        </time>

        <!-- the system gets the value automaticaly -->
        <timestamp id="4" show="no">
            <!-- if show is equal to "no", the system gets the value automaticaly 
                without interface -->
            <!-- if show is equal to "yes", the system exhibits a button to get an 
                exact time -->
            <if comparison="less" value="050000" goto="12" /> <!-- go back to bed -->
            <if comparison="equal" value="170000" goto="13" /> <!-- tea time -->
        </timestamp>

        <!-- the default for the attribute show is "no" -->
        <location id="4" required="false" show="no">
            <!-- if show is equal to "no", the system gets the value automaticaly 
                without interface -->
            <!-- if show is equal to "yes", the system exhibits a button to get an 
                exact time -->
        </location> <!-- returns Lat and Lon information using real numbers in format: "%.6f,%.6f", 
            e.g., -23.025833,-45.558611 -->

        <!-- unusual tags -->
        <!-- take a picture ‚Üí <!-- How to return control to the application??? -->
        <picture id="3" required="true">
            <help>Aponte para o foco da imagem e realize a captura</help>
            <label>tire uma foto do usuario</label>
        </picture>

        <sound id="3" required="true" duration="30"> <!-- duration is the time in seconds, if it is -1, the duration is unlimited -->
            <help>Utilize o mic para registrar o audio</help>
            <label>Registre o √°udio.</label>
        </sound>

        <movie id="3" required="false" duration="30"> <!-- duration is the time in seconds, if it is -1, the duration is unlimited -->
            <help>Aponte para o foco da imagem e realize a captura</help>
            <label>Faca um filme.</label>
        </movie>

        <!-- new tags -->
        <!-- to be used in new applications and features -->
        <component type="type_of_new_tag" id="n" required="true" a1="0"
            a2="0" a3="0" a4="0" a5="0" a6="0" a7="0" a8="0" a9="0" a10="0">
            <help>Text explaing the usage of the tag</help>
            <label>Label to be exhibited</label>
            <!-- specific sub tags if is the case -->
        </component>

        <!-- used to agregate tags -->
        <component type="container">
            <!-- any tag defined above -->
            <component type="container">
                <!-- tag1, of any type, including container -->
                <!-- tag2 -->
            </component>
            <!-- tag3 -->
            <!-- tag4 -->
        </component>
    </questions>
</form>

XML Form definition (DTD)

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <!--declaração de variáveis simples - -> <xs: element name="item" type="string"> 
        <xs: element name="item2" type="int"> <xs: element name="textArea" type="string"> 
        <xs: element name ="number" type="positiveInteger"> <xs: element name="label" 
        type ="string"> <xs: element name="help" type ="string"> <xs: element name="date" 
        type="date"> <xs: element name="time" type = "time"> <xs: element name="form"> 
        <xs: complexType> <xs:sequence> <xs: element name="component"> <xs: complexType> 
        <xs:sequence> <xs: element ref="item"> <xs: element ref="textArea"> <xs: 
        element ref="number"> <xs: element ref="label"> <xs: element ref="help"> 
        <xs: element ref="date"> <xs: element ref="time"> <xs: element ref="combo_box"> 
        <xs: element ref="check_box"> <xs: element ref="radiobutton"> </xs:sequence> 
        </xs:complexType> </xs:element><!--termina aqui o "component" -->

    <xs: element name="radiobutton" id="0">
        <xs:simpleType>
            <xs:sequence>
                <xs: element ref="label">
                    <xs: element ref="help">
                        <xs:restriction base="xs:string">
                            <xs: group name="items" minOccurs="nonNegativeInteger:1">
                                <xs:enumeration value="item">
                                </xs:group>
                        </xs:restriction>

            </xs:sequence>
        </xs:simpleType>
    </xs:element><!--termina aqui o "radiobutton" -->


        <xs: element name="checkbox">
            <xs:complexType>
                <xs:sequence>
                    <xs: element ref="label">
                        <xs: element ref="help">
                            <xs: group name="items" id="id" minOccurs="nonNegativeInteger:1">
                                <xs:element ref="item">
                                </xs:group>
                </xs:sequence>
            </xs:simpleType>
            </xs:element><!--termina aqui o "checkbox" -->


                <xs: element name="combo_box">
                    <xs: simpleType>
                        <xs:sequence>
                            <xs: element ref="label">
                                <xs: element ref="help">
                                    <xs: element name="items">
                                        <xs: sequence>
                                            <xs:simpleType>
                                                <xs:restriction base="xs:string">

                                                    <xs:enumeration value="item" />
                                                </xs:restriction>
                                            </xs:simpleType>
                                        </xs: sequence>
                                    </xs: element>
                        </xs:sequence><!--referente a "combo_box" -->
                    </xs: simpleType><!--referente a "combo_box" -->
                </xs:element><!--referente a "combo_box" -->
                </xs:sequence>
            </xs:complexType>
        </xs:element><!--termina aqui o "form" -->

</xs:schema>

References

[1] Marchal, B. XML by Example. Que Publishing, 2002.


Related

Wiki: Home

MongoDB Logo MongoDB