I am trying to display, edit with validation an object which is stored in XML in the database.
It’s shape can change over time.
I want at runtime to create a form with validation for each object stored in database.
XMl looks like this :
<root>
<name>Name</name>
</root>
View:
….
<form name="formRoot">
<p>Name</p><input name="name" value="Name"/>
</form>
….
Do you have any code examples that would help me in this matter, or if there are any libraries that do this already?
Edit 1: in c# i use this kind of xslt http://support.microsoft.com/kb/307322
Edit 2: I want to be able to add validation to each input with regex, length and type validation. Preferably using jQuery. And to do asynchronous validation as I type. For example on blur to send field name to server and get a response with valid:true if it’s valid and validation message if it is not valid.
For the XSLT part I recommend using the “Fill-in the blasnks” technique — see a simple example here: https://stackoverflow.com/a/8674694/36305.
The form skeleton will look like this:
The XSLT code will contain a template matching
gen:namethat produces:The URL to the form-skeleton is passed as an external parameter to the XSLT transformation.
The source XML document (URL or itself) is passed as another external parameter.
Thus the XSLT transformation can process any source XML document and insert the results of processing into any form-skeleton document.