I'm using Orbeon 2019.2 CE on Tomcat 8, using plain XForms.
I have xml schema for xml docs that will completed by several people, so I need to be conscious of whether the document will be valid before it is complete. For date fields, I understand there are three main ways of creating a "date or blank" type:
- using
xsi:nil
- making a union type of an xs:date and empty string
- using a list type containing an xs:date that can have a length of 0 or 1.
I've tried the 2nd and third way, this works as expected for xml validation, but in XForms where I have specified the schema in the model, the datepicker control doesn't seem to work with the custom type. I would like to use schema validation and have an empty date field be valid. (I know about xf:date
allowing no value vs. xs:date
that doesn't). There is no problem when not using schema validation, but I really would like to be able to use it as it "externalizes" validation rules to some extent. I am also using the form runner error summary component. When using validation (<model schema='uri_to_schema'>
), and a "date or nothing" type in the schema (as described above) I see this:
- If date field binding does not specify
xs:date
orxf:date
, no datepicker appears with thexf:input
field. Typing a date with the format "2000-01-01" is valid, a blank field is valid, and anything else gets flagged as invalid (both by the error component and external validation). I also noticed that Orbeon is aware that is a custom type, as the classxforms-type-custom-date-or-nothing
appears in the HTML ("date-or-nothing" is the name of the type). - If I put
type='xs:date'
in the binding for the date field, no datepicker appears, and the input is flagged as invalid (until you enter a date value) - If I put
type='xf:date'
in the binding, the field initially presents without the datepicker. If I put a valid date (format: yyyy-mm-dd), it's not flagged. If I put anything else (like 'abc'), it will be flagged by the error component, then the datepicker will appear, but it will be empty. However, in FormInspector, the field still has the invalid value, and the document (through external validation) is invalid. If I subsequently select a valid date from the datepicker, the flagged error goes away, but the field is blank again. - If I change the schema to use
xs:date
instead of the custom type ("date-or-nothing"), all is well using schema validation, except the document is invalid until it has a date value. - I have the schema instance referenced in the xform. I did try referencing the actual type from the schema by including the namespace of the schema in the xform, and then putting
type='mydoc:date-or-nothing'
, but I have not been able to get this to work. - If I remove the schema from the model and use
xf:date
in the binding, all is well but now I don't have schema validation.
Does anyone have an option where I could use the custom type and have the datepicker appear? I don't see much documentation on using XML schema with xforms, so I'm guessing this might be an "edge case" that's not supported. Is there a way to "force" Orbeon to render a datepicker? (I looked to see if I could specify the "form-runner" component there, but the documentation only mentions other date control types). In searching, I thought I saw that the xforms specification allows an "appearance='date'" attribute on the "xf:input", but this is probably wrong as I could find no other mention of this.
It would be pretty disappointing if I had to ditch schema-based validation for any document that has a date field. In some cases, I could "get away" with making the date field mandatory for the first contributor of the document, but having the option would be much better. Thanks for any suggestions!