Orbeon Forms
Search…
Generate XML Schema API

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.

Parameters

Form version

If the persistence layer on which your form is published supports versioning, by default the latest version of the form is used. If 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:
1
?form-version=42
Copied!

Data format version

The XML form data format used in the database, and by the various Orbeon Forms APIs, is typically always the same, irrelevant of the Orbeon Forms version you are on. This format is referred as the 4.0.0 format.
  • Because of this [UNTIL Orbeon Forms 2020.1], the schema API always produced a schema for data in the 4.0.0 format.
  • Should you want this API to produce a schema corresponding to another format, [SINCE Orbeon Forms 2021.1], you can specify the format you want through the data-format-version request parameter. The accepted values are:
    • 4.0.0 (this is equivalent to not having a data-format-version request parameter but allows you to be explicit)
    • 4.8.0
    • 2019.1.0
    • edge (this means "use the latest data version", which is currently equivalent to 2019.1.0; in most cases, it is better to explicitly specify the version you want, to avoid the possibility of the format changing in case a new data format is introduced by a future version of Orbeon Forms)
1
?data-format-version=2019.1.0
Copied!

Type for maybe non-relevant elements

[SINCE Orbeon Forms 2018.2.3]
When you create a form in Form Builder, if you specify a type for a field, and also make that field only show when some condition is met, should that condition not be met, then the type constraint isn't enforced as users have no way of providing a value for a field that isn't shown.
Consequently, when producing a schema from a form definition, Orbeon Forms doesn't specify the type for fields that under some condition might not be shown. Doing so would mean that, in some cases, form data that passes the Orbeon Forms validation wouldn't be considered valid according to the generated schema.
However, in some cases, you might still want to have that type information in the schema. This could be because you're not using the schema to validate data, but to extract some information from it. If you are in one of those situation, you can instruct Orbeon Forms to always generate the type for elements in the schema, even if the corresponding field might, under some condition, not be shown. This is done by adding the following request parameter to the URL:
1
?produce-type-for-maybe-nonrelevant=true
Copied!

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:
1
<xs:schema
2
xmlns:xs="http://www.w3.org/2001/XMLSchema"
3
xmlns:xf="http://www.w3.org/2002/xforms" >
4
<xs:import
5
namespace="http://www.w3.org/2002/xforms"
6
schemaLocation="http://www.w3.org/MarkUp/Forms/2007/XForms-11-Schema.xsd"/>
7
<xs:element name="form">
8
<xs:complexType>
9
<xs:sequence>
10
<xs:element name="applicant">
11
<xs:complexType>
12
<xs:sequence>
13
<xs:element name="name"/>
14
<xs:element name="business-name"/>
15
</xs:sequence>
16
</xs:complexType>
17
</xs:element>
18
<xs:element name="classification">
19
<xs:complexType>
20
<xs:sequence>
21
<xs:element name="federal-tax-classification">
22
<xs:simpleType>
23
<xs:restriction base="xs:string">
24
<xs:enumeration value="1"/>
25
<xs:enumeration value="2"/>
26
<xs:enumeration value="3"/>
27
<xs:enumeration value="4"/>
28
<xs:enumeration value="5"/>
29
<xs:enumeration value="6"/>
30
<xs:enumeration value="7"/>
31
</xs:restriction>
32
</xs:simpleType>
33
</xs:element>
34
<xs:element name="llc-classification"/>
35
<xs:element name="other-classification"/>
36
<xs:element type="xf:boolean" name="exempt-payee"/>
37
</xs:sequence>
38
</xs:complexType>
39
</xs:element>
40
<xs:element name="address-account">
41
<xs:complexType>
42
<xs:sequence>
43
<xs:element name="address-1"/>
44
<xs:element name="address-2"/>
45
<xs:element name="account-numbers"/>
46
<xs:element name="requester-name-address"/>
47
</xs:sequence>
48
</xs:complexType>
49
</xs:element>
50
<xs:element name="tin">
51
<xs:complexType>
52
<xs:sequence>
53
<xs:element name="ssn-or-ein">
54
<xs:simpleType>
55
<xs:restriction base="xs:string">
56
<xs:enumeration value="ssn"/>
57
<xs:enumeration value="ein"/>
58
</xs:restriction>
59
</xs:simpleType>
60
</xs:element>
61
<xs:element name="ssn"/>
62
<xs:element name="ein"/>
63
</xs:sequence>
64
</xs:complexType>
65
</xs:element>
66
<xs:element name="hidden">
67
<xs:complexType>
68
<xs:sequence>
69
<xs:element type="xf:date" name="current-date"/>
70
</xs:sequence>
71
</xs:complexType>
72
</xs:element>
73
</xs:sequence>
74
</xs:complexType>
75
</xs:element>
76
</xs:schema>
Copied!
Last modified 5mo ago