[Kathy Burke]
My HTML form is created by applying XSLT templates. For
example, a <measure>
element becomes an input box with the @Name applied in the XML. All
templates spring from a simple structure:
<html>
<head></head>
<body>
<xsl:apply-templates />
</body>
</html>
Then I was hoping to just add some vb or javascript to the form as
needed...is it feasible to do it this way?
Yes, very, if I am thinking the same thing as you are.
I write a JavaScript which captures the user's input and
constructs an XML
string (a
well-formed, serialized document, if you will)...
Any way you could show me a bit of an example...?
Here is a javascript function I have used in the past. It can be called
recursively. I did not need attributes in this particular application,
but it would not be hard to add them. It is simple but it produces
well-formed xml unless you work hard to defeat it.
// This function builds a tagged XML element
//with given tag name and content
function element(tag,content){
var xml
if (!content) xml='<'+tag+'/>'
else xml='<'+tag+'>' + content + '</'+tag+'>'
return xml
}
You could write something like
var xml_string = element('measure',
element(name,'Form Element 1'),
'this is a sample form element')
xml_string = element('root',xml_string)
You have to think about whether you need to escape any of the data from
the form elements (which I do not show here).
You could have your stylesheet insert the scriping code into the html
document.
Cheers,
Tom P
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list