FormToXML

Form To XML recieves HTML form data and formats it as XML.

Instructions

Create a form in which the form element names are the names of the tags to surround the data in the resultant XML document. For example to return and XML node of <Name>john<Name> you need a form with an element called "Name" and the value "John". Note that an element with a name in the parameters list below will be excluded from the XML output.
If an element name ends in a number then this element is assumed to be part of a list of elements with the same name. For example, "item1", "item2", and "item3" are assumed to be part of a list of elements with the name "item". These elements are grouped together in the XML by creating an XML node with the name "items" (note the addition of the 's'). This node will contain a node for each of the numbered elements in the form, each node will be identified with an attribute "ID" which takes the value of the number after the field name. See the Basic EMail example for a demonstration of this.

Submit the form to http://www.wkwyw.net/scripts/formToXML.jsp.

You can include a stylesheet reference by including a field called "XSLURI" which contains the URI for the styleshhet included. Note that in normal use this field would be a hidden field. The XML document will then either be transformed on the server side using this XSL or the resultant XML document will include a directive to use this stylesheet when displaying. In XML/XSL compliant browsers this translation will occur on the client side. Which action is performed is governed by the value of a parameter called "clientSideTransform" if this parameter is set to "true" then the XML document is returned for client side transformation. Any other value results in server side transformation.

If eMailTo is set then the output of this JSP will emailed to the addressed contained in that parameter. Note it is possible to send email to more than one user by setting multiple emailTo parameters (e.g. eMailTo1, eMailTo2).

Setting a value for the parameter redirectClientTo forces the client to be redirected to the URI in that parameter once processing is complete.

Parameters

Parameter Name Value Description
XSLURI XSL URI URI of the XSL document to be applied to the resultant XML form. The document will either be transformed on the client side or the server side depending on the value of the clientSideTransform parameter.
clientSideTransform "true" Indicates the XML should be returned for client side processing.
Submit any The value of this parameter has no effect on operation, but it is excluded from the resultant XML document. It is intended that the button for submission of the form will be called "Submit".
eMailTo[1..n] eMail address The address the form should be emailed to. If you wish to send the email to more than one address then simply set multiple email fields (e.g. eMailTo1, eMailTo2, eMailTo3 etc.) Note that if more than one email address is used you must use consequetive numbers in the field names.
redirectClientTo URI The URI the client should be redirected to when processing is finished. If this value is NULL or empty then the client is not redirected anywhere. Depending on other parameter settings this may result in no data being returned from the server.

 

Examples

  1. Basic form example - returns raw XML
  2. Server Side XSL example - returns the output from processing the XML with the XSL indicated in the form
  3. Client Side XSL example - returns the raw XML with an XSL directive for client side processing
  4. Basic EMail example - emails the raw XML to an indicated address
  5. Server Side Transformed EMail example - emails the result of the transformation of the XML using the indicated XSL to a given email address
  6. Client Side Transformed EMail example - emails the XML with an XSL directive to an indicated email address