What is XForms?

Category: Programming | Posted date: 2023-04-18 20:20:15 | Updated date: 2023-04-18 20:30:51 | Posted by: Admin


What is XForms?

What is XForms?

Web developers have access to many more functionalities with XForms since it provides a rich interactive experience. Many of the well-known functionalities of creating HTML forms are still retained. The following version of HTML forms is called XForms. Every time a form is opened or closed in the application, it enables businesses to automatically collect metadata like geolocation, user ID, machine ID, date, and time. Businesses can limit data entry and restrict user access for specific operations or projects inside a designated area.


XForms Features


  • A new generation of HTML forms is called XForms. It extends some properties from HTML forms while inheriting others. In other words, XForms can be thought of as HTML forms' replacement.
  • When defining data, XForms employs XML, and when displaying data, it uses HTML or XHTML.
  • The data logic of the form is separated from its appearance by XForms.
  • Form data is defined by XForms using XML.
  • XForms stores and transmits data using XML. Data submitted from a form is transmitted over the internet using XML, as are the data that are displayed in the form and stored in an XML document.
  • Because data and presentation are separated in XForms and the data model is applicable to all devices, the software is device independent.
  • A W3C recommendation is XForms.

XForms Functions


  • boolean-from-string(string) - If the given string is "True" or "1," it returns TRUE; otherwise, it returns FALSE.
  • if(boolean test, string1, string2) - When the Boolean test parameter is evaluated, string1 is returned if the test is true, and string2 is returned if the test is false.
  • avg(node-set) - It provides the average value for each node in the provided node-set. The value of each node is converted into a number. The return value is nan <div><values> if the node-set is empty.

<value>10</value>

<value>50</value>

<value>0</value>

</values>


avg(/values/value)


returns: 20

  • min(node-set) -  It is employed to determine the overall node set's minimum value. Each node's value is transformed into a numerical value. if the node-set is not present it returns nan<div><values>

<value>10</value>

<value>20</value>

<value>0</value>

</values>


min(/values/value)


returns: 0

  • max(node-set) - It provides the nodes in the supplied node-set's maximum value. Each node's value is transformed into a numerical value. if the node-set is not present it returns nan<div><values>

<value>10</value>

<value>20</value>

<value>0</value>

</values>


max(/values/value)


returns: 20

  • count-non-empty(node-set) - It gives back the quantity of non-empty nodes in the given node-set.<values>

<value>10</value>

<value>20</value><div><value>0</value>

<value />

</values>


count-non-empty(/values/value)


returns: 3

  • index(string) - It provides the most recent index for the specified repeat set.
  • property(string) - It gives back the attribute specified by the string parameter.

div>property("conformance-level") returns the xforms conformance level ("basic" or "full") property("version") returns the xforms version number

  • now() - It provides the xs:datetime formatted current system date and time.
  • instance(string) - More than one instance can be found in an xforms model. This function returns the datadiv> instance's root node for the supplied instance.<xforms:instance id="orderform">

<firstname>john</firstname>

</xforms:instance>


ref="instance('orderform')/firstname"

The firstname element node from the instance "orderform" is what this example returns as a node-set.

  • days-from-date(string) - It returns the number of days between the supplied date and 1970-01-01 if the text parameter is a valid xs:date or xs:datetime; otherwise, it returns nan.

days-from-date("2002-01-02") returns 11689

days-from-date("1969-12-29") returns -3

  • seconds-from-datetime(string) - It returns the number of seconds between the supplied datetime and 1970-01-01t00:00:00z if the text parameter is a valid xs:datetime; otherwise, it returns nan.
  • seconds(string) - It returns the number specified in the seconds component plus 60 * the number specified in the minutes component plus 60 * 60 * the number specified in the hours component plus 60 * 60 * 24 * the number specified in the days component if the string parameter represents a legal xs:duration; otherwise, it returns nan. 

seconds("p1y2m") returns 0

seconds("p3dt10h30m1.5s") returns 297001.5seconds("3") returns nan

  • months(string) - It returns the number supplied in the months component plus 12 * the number specified in the years component if the string parameter reflects a lawful xs:duration; otherwise, it returns nan.

months("p1y2m") returns 14

months("-p19m") returns -19



Advantages of XForms


  • A feature of XForms is its device independence. An XForm can be used on any XForms-compatible device, such as a web page in a browser, a PDA, or a mobile phone, once it has been built. Because the presentation is done by the device itself, there isn't really anything that has to be updated in the XForm. There is already a substantial number of browsers or browser plugins (for PCs and mobile devices) available for XForms.
  • Due to the fact that XML technologies frequently prioritize data over appearance, XForms separate content from presentation. XForms, however, can be altered using, for example. XHTML that has been formatted using an XSLT stylesheet for viewing in a standard browser.
  • Take into account the fact that XForms do not require you to specify a date, although HTML forms do. The server must confirm that the date is typed correctly and that what you have sent is in fact a date when you submit a form. The XForms device does the checking before transmitting the data.
  • When the "Male" checkbox in an eCRF is chosen, questions about pregnancy might immediately be blanked out. This is just one example of how XForms can be dynamic. Alternatively, the questions about pregnancy are already blanked out when the XForms are loaded if the database reveals that the subject is male.
  • XForms decouple presentation from data. The XForms document, which is an XML or XHTML page, contains the data and input fields, but the presentation (styling, fonts, and colors) is kept in a cascading stylesheet file (CSS). So, if you don't like how a page looks on a website, PDA, or mobile device, you can simply update or replace the CSS. This suggests that you can deploy on several devices without modifying the XForms page by simply utilizing a new CSS file.
  • Automatic XForm generation is possible, for instance, from XML documents. In our example, we demonstrate how an automatically generated set of XForms that can be used in web browsers, PDAs, or mobile devices may be created from a CDISC ODM Study specification using XSL technology. This implies that the transformation stylesheet only needs to be created once, and that the required forms can subsequently be generated automatically for each new research (or study update).
  • XForms deliver their data in XML format to the server. This indicates that the server will find it considerably simpler to decode the data and store it (most often in XML format).
  • Data from an XForms object may be stored locally. One cannot anticipate that the device will be always connected to the server when the form is filled out, for example, in a hospital setting (or in the case of a patient journal). When using XForms, the instance data—the information that was filled out—can be saved and accessed at any time. This implies that the form's data can be stored on the device so that an investigator, for instance, can later complete it. When the investigator connects his device to his personal computer (using, for example, a PDA on a cradle), all stored XForms can be sent to the server if there is no wireless connection available.

Final Thought


The function and display of a form cannot be distinguished in conventional HTML Web forms. XForms, on the other hand, are split up into sections that define the form's purpose and look. This makes it possible to connect an XML form specification to flexible display options, like standard XHTML forms.


Copyright 2025 IFormatLogic IT Solutions