Search code examples
xmlxsdxforms

Can I use an existing XSD Schema for my XForms model


I'm reading the XForms 1.1 spec. I haven't read the whole thing yet as its dense and hard to read. The spec suggests I can define XSD constraints on my XForms model fields inline or imported from external XSD files. xforms:model also has a schema attribute which pulls in XSD schema. But its unclear to me exactly how I can use an XSD schema:

  1. Can associate ("bind") an xforms model element with a complexType or an XSD element with complexType?
  2. Can I skip the XForms model entirely and just use the XSD schema?!

I've really been chasing the second question. I don't think its the way it works, but it would be sweet if it worked that way.


Solution

  • XThe answer is NO to both questions:

    1. Although the specification states that XForms processors must process the simple and complex types in the schemas, none of the existing processors support complexTypes (at least to my knowledge), only simpleTypes in <xf:bind>.

    2. Would be wonderful using a schema on XForms and all the constraint information on it, but instead you have to create an instance document and write the bindings one by one.

    My suggestion is: write your own custom XForms generator from your schema to avoid writing all bindings manually. Or add a validation step before submitting your XForms that validates the instance document against your schema.