I know there is a lot of documentation on the internet as far as XSD to forms, but I have not been able to come across one that is straight forward enough for my situation.
I am working with a WCF web service that is going to fetch and .xsd xml schema, and must return the HTML of a form based on the .xsd xml schema. Is there any third party tools that can help out with this, if so wh开发者_Python百科at are they? If not, do you have any suggestions,better methods,etc for how this can be done?
I am working on my own project called XsdFormEditor. Application will be able to show any XSD as a form in WinForms (95% done), Web (using Asp.Net MVC, 0% done), WPF (0% done). Idea is to load any XSD file, show it to user as a form, let user input some data and save data as XML. User will be also able to load default values to form from XML file. You can find it here: https://github.com/janstafa/XsdFormEditor
Xsd is difficult to parse, but you can easily obtain a class from it, by calling xsd.exe /class or by doing it runtime following this beautiful sample: http://mikehadlow.blogspot.com/2007/01/writing-your-own-xsdexe.html hence with the classes representing your xsd you can use reflection to create the html code.
First of all, they will need not only to pass you the XSD (with no include
, import
or redefine
elements in it), but will also need to tell you the root node.
Second, I would approach this by reading in the XSD with the XmlSchema.Read
method. You could then loop through the object model pulling the information you need.
You might even try writing out an XML document containing the parts of the schema that you really need, and then running an XML Transform against it to produce the HTML.
Also, consider the Microsoft Office InfoPath product from Microsoft. Even if you don't wind up using the product itself, get a trial version to see how forms can be defined based on XSD plus other metadata.
精彩评论