XFORMS

XForms Projects

XForms Project 1

XForms Examples

XForms EXAMPLE

XFORMS Subective Questions And Answers

More interview questions and answers

What is XForms?

We can define XForms as the new generation of HTML forms.

In an XForms we use XML to create input forms on the Web.

Some other points about XForms are given below:

1. Using XForms we can generate forms that are   much richer and flexible than HTML forms.

2. XForms will act as form standard in XHTML2.0.

3. XForms is plateform independent and it is also device independent.

4. Use XForms to seperate logic and device from presentation.

5. Using XForms we can define data of form.

6. We can use XForms to stores and transport data into an XML document.

7. XForms also have some features like using XForms we can perform calculation and also to validate our forms.

8. XForms also help us to reduce or eleminate need of scripting. 

9. XForms also a W3C Recommendation.

How we can say XForms is succesors of HTML forms?

With using HTML forms web application are become able to accept input from user.We can say that HTML forms is a part of HTML standard.Now,web user try to solve complex transactions but HTML standard does achieve that task.

We can achieve that task using XForms.Because using XForms handle a richer,more secure and device independent web input.

XForms are supported by all future browsers.

 

How Xforms is used to separate data from presentation?

Using XForms we can perform both task to define data and to display data.To define data XForms uses XML and to display data XForms uses HTML or XHTML.

Using XForms we can separate data logic of a form from its presentation.

How we store and transport data using XForms?

We can perform task of store and transport data using XForms. Using XForms we can store data or to submit data from the form. We use XML to transfer data over the net.Keep in mind XForms Store and Transform data in the form of Unicode bytes.

 

How we can say XForms is device independent?

We can say that XForms is device independent because it is used to separate data from presentation and we can use data models for all devices. Using XForms we can customize presentation for different user interface.Like mobile phones, handheld devices etc.

Using device independent features of XForms we can add XForms element into othe XML application directly.i.e.WML(Wireless Markup Language),VoiceXML(Use to speak web data).

How we can say XForms has W3C Recommendation?

W3C Recommended XForm 1.0 in Oct 2003.We can say that it is a new generation version of HTML. 

How to define XForms Framework?

 Basically main purpose of XForms is to collect data.

 We can describe input data using XForms into two different parts.

1. XForm model

2. XForm user interface

   We use XForm model to describe the data and the logic means using XForm we can define what the form is, what data it contains and what it should do.

   We use XForm user interface to perform input and output task on data means that XForms user interface use to define the input fields and how they should be displayed. 

How you define XForms model?

To describe the data we use XForms Model.We can also say that datamodel is an instance of XML document.We define data model into the XForms, inside a <model> element.

Example:

<model>

<instance>

<person>

<fname/>

<mname/>

<lname/>

</person>

</instance>

<submission id=\"form1\"

action=\"submit.asp\"

method=\"get\"/>

</model>

In the above example we uses <instance> element that is use to define the XML template for data to be collected and a <submission> element is used to define how we submit a data.


The <instance> Element: Using <instance>element we can define the data that we collected.

We use XForms to collect data for an XML document.And <instance> elementis use to define the XML document in XForms model.

Example:

<person>

<fname/>

<mname/>

<lname/>

</person>

 When XML data collect the data it will looks like that,

<person>

  <fname>vivek</fname>

  <mname>kumar</mname>

  <lname>agarwal</lname>

</person>

The <submission> Element: Using this element we can describe how to submit a data into an XML document.

Example:

<model>

<instance>

<person>

<fname/>

<mname/>

<lname/>

</person>

</instance>

<submission id=\"form1\"

action=\"submit.asp\"

method=\"get\"/>

</model>

In the above example we use attribut id=\"form1\" attribute  to identify the form.And uses the action=\"submit.asp\" attribute to define the URL to where the form should be submitted and use method=\"get\" attribute to define the method which is use to submit the data.


How you define XForms User Interface?

 We use XForms user interface to display and get input the data.

 We called user interface elements of XForms as controls or input controls.

Example:

<input ref=\"fname\"><label>First Name</label></input>

<input ref=\"mname\"><label>Middle Name</label></input>

<input ref=\"lname\"><label>Last Name</label></input>

<submit submission=\"form1\"><label>Submit</label></submit>


 In the above given I have use three <input> elements to define input fields.

 In example ref=\"fname\", ref=\"mname\" and ref=\"lname\" attributes which is use to point <fname>,<mname> and <lname> elements in the XForms model.

 We use submission=\"form1\" attribute which refers to <submission> element in the XForms model.

 In the above example we use <label> elements With XForms every input control element.

How to use both XForms Model and XForms User Interface togather?

 We can use both XForms Model and XForms User Interface togather like that,

Example:

<xforms>

<model>

<instance>

<person>

<fname/>

<mname/>

<lname/>

</person>

</instance>

<submission id=\"form1\"

action=\"submit.asp\"

method=\"get\"/>

</model>

<input ref=\"fname\"><label>First Name</label></input>

<input ref=\"mname\"><label>Middle Name</label></input>

<input ref=\"lname\"><label>Last Name</label></input>

<submit submission=\"form1\"><label>Submit</label></submit>

</xforms>

How you define XForms Processor?

We use XForms Processor inside the browser to submit XForm data to the target.

I have you example show how to submit data into XML. 

Eaxmple: 

<person>

  <fname>vivek</fname>

  <mname>kumar</mname>

  <lname>agarwal</lname>

</person>

How you define XForms Namespace?

 XForms Namespace are used in HTML and XHTML1.0.We can perform task to use XForms Namespace to declare all XForms element with XForms Namespace.

 I have given you example which shows how to use XFoms Namespace.

Example:

<html xmlns:xf=\"http://www.w3.org/2002/xforms\">

<head>

<xf:model>

<xf:instance>

<person>

<fname/>

<mname/>

<lname/>

</person>

</xf:instance>

<xf:submission id=\"form1\" method=\"get\" action=\"submit.asp\"/>

</xf:model>

</head>

<body>

<xf:input ref=\"fname\">

<xf:label>First Name</xf:label></xf:input>

<br />

<xf:input ref=\"mname\">

<xf:label>Middle Name</xf:label></xf:input>

<br />

<xf:input ref=\"lname\">

<xf:label>Last Name</xf:label></xf:input>

<br />

<br />

<xf:submit submission=\"form1\">

<xf:label>Submit</xf:label></xf:submit>

</body>

</html>

 In above example we use XForms Namespace as \'xf:\'.And you can use this XForms Namespace to call any thing.

WHat is Binding in XForms?

When XForms achieve that task to address data in XForms with use of XPath.Than it is called as Binding.

I have allready told you XForms define data in two sections.These sections are: XForms model(is a XML instance for data) and XForms user interface(used to describe input and presentation of data).

Than we can say that In Binding we use XPATH to made connection b/w them(these two sections).

Define XPath?

We use Xpath to define parts of an XML document.It is an W3C standard.

Main task given by XPath is that,

XPath uses pth expression which helps to identify each node of an XML document.

I have given you a path expression like that,

/person/lname

We use this path expression to address the node lname.

<person>

   <fname>vivek</fname>

   <mname>kumar</mname>

   <lname>agarwal</lname>

</person>

How to perform bindimg using ref atribute?

How to perform binding using bind attribute?

 We can also perform binding b/w the XForms model and XForms user interface With bind attribute like that,

Example:I have given you XForms model instance:

<model>
<instance>  
<person>    
<name>      <fname/>      
<mname/>      
<lname/>    
</name>  
</person>
</instance>
<bind nodeset=\"/person/name/fname\" id=\"firstname\"/>
<bind nodeset=\"/person/name/mname\" id=\"middlename\"/>
<bind nodeset=\"/person/name/lname\" id=\"lastname\"/>
</model> 

Now, Using bind attribute XForms user interface can bind <input> elements like that:

<input bind=\"firstname\">
<label>First Name</label>
</input>
<input bind=\"middlename\">
<label>Middle Name</label>
</input>
<input bind=\"lastname\">
<label>Last Name</label>
</input>

 Using binding we can easily deal with multiple instance model and multiple forms.

How you define controls in XForms?

 XForms controls are also told as user interface elements we use to control user interface of XForms.

I have given you some main common controls given below:

<input>

<submit>

 a ref attribute is attach with each controls element.That is use to point the XForms data model of each control element.


How you define input control?

 One of the most common XForms control is input control.

Example:

<input ref=\"name/fname\">

<label>First Name</label>

</input>

<input ref=\"name/mname\">

<label>Middle Name</label>

</input>

<input ref=\"name/lname\">

<label>Last Name</label>

</input>

These input control will display like that,

First Name:

Middle Name:

Last Name:


What is label element?

 I told you when you want to perform input controls than <label> element is necessary child element for this.

 Because with use of <label> element is secure and we used  that forms in all different types of devices.i.e. Label will be spoken for voice software. 

How to perform secret control?

 The secret control are degined to perform some special task like that input passwords or other hidden information:

<secret ref=\"name/password\">

<label>Pass:</label>

</secret>


How to perform Textarea control?

 Using textarea control we can perform task to control multi-line user input.

<textarea ref=\"message\">

<label>Message Box:</label>

</textarea>

How to perform output control?

 Using output control we can control how to display Xform data.

Example:

I have given you a instance of XML document.

<instance>

<person>

<name>

<fname>vivek</fname>

<mname>kumar</mname>  

<lname>agarwal</lname>

</name>

</person>

</instance>

 We can perform output control on above XML instance.

<p>First Name: <output ref=\"name/fname\" /></p>

<p>Middle Name: <output ref=\"name/mname\" /></p>

<p>Last Name:  <output ref=\"name/lname\" /></p>


Output:

Firse Name: vivek

Middle Name: kumar

Last Name: agarwal

How to perform Upload Control?

 We use upload control perform task to control when we uploaded files into server.

<upload bind=\"name\">

<label>File is used to upload:</label>

<filename bind=\"file\"/>

<mediatype bind=\"media\"/>

</upload>

How to perform selection control in XForms?

 When we want perform control on one or more items in user interface of XForms we use Selection control.

I have perform three type of selection control. These are,

1.Select1 Control

2.Select Control

3.Range Control

1.Select1 Control: When we want to select one item from list of items we use Select1 Control. 

Example:

<select1 ref=\"status\">

  <label>Status:</label>

  <item>

    <label>Married</label>

    <value>M</value>

  </item>

  <item>

    <label>Unmarried</label>

    <value>UM</value>

  </item>

</select1>

 In this example user can select only one status Married or Unmarried.And it will stored in the XForms instance of XML document like M and UM.


2. Select Control: When we want to select one or more items from list of items we use select control.  

Example:

<select ref=\"languages\">

<label>Languages:</label>

<item>

    <label>English</label>

    <value>E</value>

</item>

<item>

    <label>Hindi</label>

    <value>H</value>

</item>

<item>

    <label>French</label>

    <value>F</value>

</item>

<item>

<label>Spanish</label>

<value>S</value>

</item>

<item>

<label>German</label>

<value>G</value>

</item>

</select>

 Now, In the above example user can select more than language.


3. Range Control: Using Range control we can select a value from a range of values.

Example:

<range ref=\"length\" start=\"0\" end=\"200\" step=\"10\">

<label>Length:</label>

</range>

 Now, In the above example user can select a value between 0 and 200 in steps of 10.


How you define data types in XForms?

XML Schema data type supported by XForms model.


XML Schema Data Types: Because XFormes model supports XML Schema data types. Using this feature XForms processor check the data for correct input values.

If we want to use XML Schema data types, we must have to use XML Schema namespaces into our namespace declaration,

Example:

<html

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\">


 After using the XML Schema namespaces, we can add type attributes into our XForms instance elements like this:

Example:

<xf:instance>

<person xmlns=\"\">

  <fname xsi:type=\"xsd:string\"/>

  <lname xsi:type=\"xsd:string\"/>

  <born  xsi:type=\"xsd:date\"/>

  <size  xsi:type=\"xsd:integer\"/>

</person>

</xf:instance>

 I haven given you a list of XML Schema data types except that XForms uses all XML schema data type.

  List of unsupported XML Schema datatype in XForms.

1.duration

2.ENTITY

3.ENTITIES

4.NOTATION


How to bind datatype in XForms?

 If you want bind data types in XForms than you have to use <bind> element. which is use to bind datatype with their instance data.

Example:

<xf:bind nodeset=\"/person/size\" type=\"xsd:integer\"/>

How to perform Actions in XForms?

 Using Actions we handle response to events in XForms.

 Actions that we use in XForms are given below:

1. Meassage Action 

2. Setvalue Action


1. Messsage Action: We use <message> element in XForms to defines a message.And to display that message into XForms user interface.

Example:

<input ref=\"fname\">

<label>First Name</label>

<message level=\"ephemeral\" event=\"DOMFocusIn\">

Enter Your First Name

</message>

</input>

 In this example the message \"Enter Your First Name\" will displayed as a tool tip when user will focus on the input field.

 And the event=\"DomFocusIn\" is use to define the event to trigger that action.

 And the level=\"ephemeral\" is use to define the message that will display as a tool tip.


2. Setvalue Action: We use <setvalue> element in XForms to set a value that will show with response of an event.

Example:

<input ref=\"size\">

<label>Size</label>

<setvalue value=\"100\" event=\"xforms-ready\"/>

</input>

 In this example instance element <size> will stores a value 100 when the form opens.


How you define functions in XForms?

 I cleared you XForms already have some functions and we can also call the function those are in Script.

I have you some list of functions that we used in XForms. 

boolean-from-string(string) : This functon return true and false when its string parameters are \"true\" or \"1\" and \"false\" or \"0\" respectively. 


if(booleantest, string1, string2) : First it perform the booleantest and return sting1 if test is true or return string2 when test is false. 


avg(node-set) : It returns the average of all nodes that are in specified node-set.It returns NaN when node-set is empty.

<values>

<value>20</value>

<value>25</value>

<value>0</value>

</values>

avg(/values/value)

 It will returns: 15


min(node-set) :It returns the minimum value of all nodes of a specified node-set.It returns NaN

when node-set is empty.

<values>

<value>20</value>

<value>25</value>

<value>0</value>

</values>

min(/values/value)

 It will returns: 0


max(node-set) :It returns the maximum value of all nodes of a specified node-set.It returns NaN

when node-set is empty.

<values>

<value>20</value>

<value>25</value>

<value>0</value>

</values>

max(/values/value)

 It will returns: 25


count-non-empty(node-set) : It returns the number of non-empty nodes of a specified node-set

<values>

<value>20</value>

<value>25</value>

<value>0</value>

<value />

</values>

count-non-empty(/values/value)

 It will returns: 3


index(string) :It returns the current index of a given repeat set.


property(string) : It returns property that named by string parameter.

property(\"version\")-It is use to return the XForms version number.

property(\"conformance-level\")- It is use to returns conformance level (\"basic\" or \"full\") of XForms.


now() :It returns current system date and time in xs:dateTime format.


instance(string) : XForms Model may have more  than one instance. It returns the root node of the specified instance data

<xforms:instance id=\"orderform\">

<firstName>vivek</firstName>

<middleName>kumar</middleName>

<lastName>agarwal</lastName>

</xforms:instance>

ref=\"instance(\'orderform\')/firstName\"

 It returns a node-set that consists of the firstName element node from the instance named \"orderform\"


How you define properties of XForms?

 Properties helps to define data restrictions, types and its behaviour in XForms.

I have given you some properties.

1. required=\"true()\" property : This property it doesn\'t allow to submit an empty value to specified instance data.

2. type=\"decimal\" property : Using this property we can submit only decimal value.

3. calculate property : Using this property we can calculate a value of instance data.


 Using <bind> element we can also bind XForms property with XForms data.To understand this i have given you a example.

<model>

<instance>

  <person>

      <fname/>

      <mname/>

      <lname/>

  </person>

</instance>

<bind nodeset=\"person/mname\" required=\"true()\"/>

</model>

 This example shows that the attribute nodeset=\"person/mname\" binds the property required=\"false()\" with instance data element <mname>.means don\'t write middle name here.

XFORMS Subective Questions And Answers