Projects‎ > ‎XForms‎ > ‎

XForms Without Namespaces

NOTE: This page describes an Orbeon Forms project, not a feature which is currently part of Orbeon Forms.


A typical XForms+XHTML page typically uses at least 3 to 5 namespaces, sometimes more:
  • XForms
  • XML Events
  • XML Schema types
  • extension namespaces (Orbeon xxforms:*)
  • etc.
This document explores how the XForms+XHTML stack can be written without any namespaces.

Issues to solve

Element name conflicts

Conflicts can arise, for example: how to make a distinction between:
  • <xhtml:input> or HTML <input>
  • and <xforms:input>
Possible solutions:
  1. Bad: prevent use of HTML input!
  2. Better: infer the element based on attributes
  3. Best: XForms input is an extension of HTML input
Solution #2 is a good middle ground: if the input element has any of these attributes, then it is an XForms element:
  • ref
  • bind
  • context
  • model
Elements that can conflict:
  • input: solution #2
  • textarea: solution #2
  • select: solution #2
  • label
    • if whithin XForms element, then XForms
    • if for to XForms element, then XForms

Attribute names conflicts

These shouldn't happen.

Content to preserve

Content of some elements must be preserved, with namespaces if needed:
  • <instance>
  • <schema>
  • any other?

Foreign attributes

XML Events attributes must be placed in the correct namespace.


[TODO: any issue here?]

Other Orbeon namespaces

[TODO: fr, fb, etc.: how are those handled?]

Formal rules

  1. If an element has an explicit prefix, the corresponding namespace is used.
  2. instance is in the XForms namespace, and none of the following rules apply to its content.
  3. schema is in the XML Schema namespace, and none of the following rules apply to its content.
  4. If an element is defined by XForms (group, repeat, …), it is in the XForms namespace.
  5. If an element is defined by both XForms and (X)HTML, namespace is determined based on context:
    • it is in the XForms namespace if it has at least one of ref, bind, context, model attributes
    • or if it is the <label> element and is linked to an XForms element (by nesting or using for)
  6. If an element ends in the XForms namespace, any attribute matching an XML Event attribute is put in the XML Events namespace.
  7. Finally, if none of the above applies, the element is in the XHTML namespace.


As a first step, a simple XLST transformation can convert from no-namespace XForms to full namespaced XForms+XHTML.


Version of the XForms Hello example.

        <title>XForms Hello</title>
            <i>This example is described in details in the <a href="/doc/intro-tutorial">Orbeon Forms Tutorial</a>.</i>
            <input ref="/first-name" incremental="true">
                <label>Please enter your first name:</label>
            <output value="if (normalize-space(/first-name) = '') then '' else concat('Hello, ', /first-name, '!')"/>

Simple trigger with event handler:

    <setvalue event="DOMActivate" ref="instance('lang')"
              value="if (. = 'en') then 'fr' else 'en'"/>