XML Schema Generation

Availability

This is an Orbeon Forms PE feature.

What it does

This is a Form Runner service that generates an XML Schema 1.0 or 1.1 schema for a published form. The schema is specific for the app and form name selected.

You access the service using the following URL:

  • Orbeon Forms 4.4 and newer: /fr/service/[app]/[form]/schema
  • Orbeon Forms 4.0 to 4.3: /fr/[app]/[form]/schema

With 4.4 and newer, the service must be authorized like other services.

The service assumes that the data model of the form is standard XML data model as generated by Form Builder. Custom XML data models are not supported.

Form version

If the persistence layer on which your form is published supports versioning, by default the latest version of the form is used. Instead, you'd like to produce the schema for a specific form version, you can pass that version number with the form-version request parameter, e.g. in 4.4+ /fr/service/[app]/[form]/schema?form-version=42.

Limitations

  • Not all form validations can be encoded in an XML Schema. For example, validations specified with the XForms constraint attribute are not present, as they are expressed with XPath an XML Schema 1.0 does not support XPath constraints.

Example

Here is the schema produced for the W9 form as of Orbeon Forms 4.4:

<xs:schema
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xf="http://www.w3.org/2002/xforms" >
    <xs:import
        namespace="http://www.w3.org/2002/xforms"
        schemaLocation="http://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd"/>
    <xs:element name="form">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="applicant">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="name"/>
                            <xs:element name="business-name"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="classification">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="federal-tax-classification">
                                <xs:simpleType>
                                    <xs:restriction base="xs:string">
                                        <xs:enumeration value="1"/>
                                        <xs:enumeration value="2"/>
                                        <xs:enumeration value="3"/>
                                        <xs:enumeration value="4"/>
                                        <xs:enumeration value="5"/>
                                        <xs:enumeration value="6"/>
                                        <xs:enumeration value="7"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                            <xs:element name="llc-classification"/>
                            <xs:element name="other-classification"/>
                            <xs:element type="xf:boolean" name="exempt-payee"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="address-account">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="address-1"/>
                            <xs:element name="address-2"/>
                            <xs:element name="account-numbers"/>
                            <xs:element name="requester-name-address"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="tin">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="ssn-or-ein">
                                <xs:simpleType>
                                    <xs:restriction base="xs:string">
                                        <xs:enumeration value="ssn"/>
                                        <xs:enumeration value="ein"/>
                                    </xs:restriction>
                                </xs:simpleType>
                            </xs:element>
                            <xs:element name="ssn"/>
                            <xs:element name="ein"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
                <xs:element name="hidden">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element type="xf:date" name="current-date"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>