This post JSON shows how to create a JSON from JSON schema using Java Metawidget. I want to do exactly the same for an XSD (and if necessary XML).
The metawidget documentation says quite a bit about XMLInspectors, but I have not been able to get a result after some trial and error (and i did not find any examples). Do any of you have any idea if and how the whole thing works with Metawidget? If this should not go with Metawidget, I would also be open for alternatives to Metawidget. I want to create the form dynamically. This means that during runtime a form should be created from passed xsd(s), from which an XML is then generated (in java).
Metawidget already has an XmlSchemaInspector which may do what you need.
Beyond that, Java Metawidget's internal inspection format is already XML (albeit a String of XML, to avoid dependencies). See section 2.2.6 in the documentation:
So you would need to create your own Inspector, that read your own XML format, and manipulated it into the format above. Then return that as a String.
See section 2.2.7 in the documentation. For inspecting XML files,
BaseXmlInspector
assists in opening and traversing through the XML, as well as merging multiple XML files into one (e.g. merging multiple Hibernate mapping files).It also lets you work with parsed XML as Maps, which is a bit easier, and does the conversion for you. See: