XForms Data Types

XForms models support XML Schema data types.

XML Schema Data Types

XForms models support XML Schema data types. This feature enables XForms processors to check the data to ensure the correctness of input values.

You can find more about XML Schema in our XML Schema Tutorial Learn more about XML Schema instructions.

You must add the XML Schema namespace to the namespace declaration to use XML Schema data types, as follows:

<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 adding the XML Schema namespace, you can add the type attribute to the XForms instance element like this:

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

XForms supports all XML Schema data types except the following types:

  • duration
  • ENTITY
  • ENTITIES
  • NOTATION

For a complete reference of XForms data types, please visit:

Complete XForms Data Types Reference Manual

Try it yourself

Data Type Binding

In XForms, you can also use the <bind> element to associate instance data with data types:

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