XML / XSD - Form validation help

Associate
Joined
6 Nov 2007
Posts
23
Hi Guys,

Wondering if any of you could help me with this at all..At least where to look. I have been asked to look at a solution which involves

"This application will process an XML file consisting of a sequence of definitions, and produce both the form and the relevant validation code
(in JavaScript). The form need not be in HTML"

I need to somehow automatically produce the javascript. The only way I can think of doing this is using xslt but I have no idea how to produce the validation.

If anyone understands this and can help at all I will be grateful!

Thanks
 
Hi,

One way you could do this would be to write a library of JavaScript validation routines in a JavaScript file that your page includes. The HTML produced from the XSLT would then produce JavaScript code to call these functions, rather than producing the validation code itself.

For example, you could have a function in your library:

isBetween(min,max,errormessage);

This would be called to determine if a field lay between two values, and if not pop up an error message. The XSLT would need to generate code to call this routine. Producing the calls to the functions would be considerably easier than generating the actual validation code each time, and also separates the validation logic from the XML/HTML.

An alternative may be to convert the HTML form back into XML and use a schema to pick up any errors in content.

Finally, have you had a look at XForms? I'm not familiar with this but from a quick look there might be some stuff in that which could help you.

Does that help?

Jim
 
Back
Top Bottom