XSD to HTML Form
I’ve been tasked with building a web-based interactive SDK to speed up client-side development for our RESPful Web Service APIs. Part of the solution requires an engine that can read an XSD and dynamically generate an editable html form. The idea is to have the user populate the online form to generate a valid XML document. I’m hoping to find a product or library that will help get us there as opposed to building this from scratch. We are looking to integrate this in a tomcat/jsp/java environment. Here are some of the requirements:
(1) Support XSD include & group elements (100+ services are in 2 XSD files bound by include)
(2) Allow selection (via configuration) of an element node to generate form (subset of XSD)
(3) Form should allow data entry of Elements and Attributes
(4) Support 0 to unbound occurrences of any type in Form (add/delete/collapse)
(5) Form widgets:
a. Radio buttons for Choice
b. Checkboxs for Boolean
c. DropDown Lists for Enumerations
d. Datepickers for Dates
(6) Allow for adding default data on the Form
(7) XSD validation should be integrated in the Form highlighting fields in error
(8) Open-source and extendable
*Constraint: I’m building a layer on top of existing services and I don’t have access to modify the XSDs.
I’ve looked at xsd-forms (code.google.com/p/xsd-forms) and it looks promising but it’s in pre-alpha status. Also looking at XSDForm (www.ilerian.com/xsd-web-form-overview) but it may be difficult to integrate with our technology stack and does only part of what we need (but still looking at it). Any ideas or recommendations?
I know this is an old question, but I ran into this issue myself and couldn't find a satisfying open-source solution. I ended up writing my own implementation, XSD2HTML2XML. To my knowledge it is the most complete tool out there. It supports a lot of what the topic starter asked for (and a lot more :)):
- automatic generation of HTML form from XSD; includes and groups are supported.
- selection of a subset of an XSD is NOT supported.
- elements and attributes are both supported.
- minOccurs and maxOccurs are both supported.
- GUI elements are determined by types, so radio buttons, checkboxes, dropdown lists, and datepickers are all supported.
- Default (and fixed) data is supported. This includes data from an external XML document.
- HTML5 attributes (pattern, min, max, etc.) are used for validation. How validation is shown to the user depends on browser implementation.
- Open source under MIT license.
If you prefer an out-of-the-box solution rather than writing your own, please see my implementation, XML Schema Form Generator.