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:
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 adata-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 to2019.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)
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:
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:
Last updated