1

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.

0

1 Answer 1

1

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:

<form name="formRoot" xmlns:gen="my:gen">
  <gen:name/>
</form>

The XSLT code will contain a template matching gen:name that produces:

<p>Name</p><input name="name" value="Name"/>

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.