HtmlToXml is the HTML-to-XML conversion tool with Java Swing GUI.
It generates the XML, which can be used for the input validation from the CGI FORM.
As you learn by another tutorial, HtmlToXml reads a pair of the normal HTML.
While in the conversion, it will ask you to specify the acceptable data type for each input of the CGI FORM.
Along with a set of the tags in the HTML to be read, these information are merged into the single XML.
The Java API by OOP-Reserch, such as ViewGenerator, can use this XML for the input validation from the CGI FORM.
HtmlToXml can also generate the template for the dynamic response. In this tutorial, this kind of XML is called template XML. The template XML is simpler than the XML for the input validation, because the validity of each value do not matter. By the help of the Java API by OOP-Reserch (such as ViewGenerator), your Servlet can insert the values between the tag groups in the template XML. And your Servlet can send the concatenated tags back to the web browser.
For example, your Servlet may query the SQL table and insert the selected data between the tag groups of the template XML.
Because HtmlToXml conversion tool reads the normal HTML (or any other mark-up-languages, such as XHTML, WML or HDML), the web designers (or page authors) need not learn even a bit of JSP or custom tag libraries. They can design the view part of the web application in their favorite tools.
In addition, this template strategy makes Localization (L10n, Japanese message for Japanese users and Chinese message for Chinese users) much easier than the JSP/JSTL based-solution, such as Apache Struts or JavaServer Faces. Localization (L10n) by the JSP/JSTL fully depends on the resource bundle, i.e. the localized messages should be written in the property resource files for each Locale, in case of Apache Struts or JavaServer Faces. As for HtmlToXml, what you (Java programmer) need is the normal HTML for each Locale. Each of these HTML will include the localized message for the intended Locale. Once the HTML for each Locale is prepared, HtmlToXml conversion tool will convert it into the template XML for each Locale. That's all!
This is the step-by-step tutorial about how to generate the template XML from the normal HTML. If you are not familiar with HtmlToXml conversion tool yet, please read another tutorial first.
As introduced in the previous section, the template XML can be used to generate the dynamic response by your Servlet.
For example, your Servlet may query the SQL table and insert the selected data between the tag groups of the template XML. And your Servlet can send the concatenated tags back to the web browser.
Through this example, we will generate the template XML with the HTML table. In each cell of this HTML table, your Servlet can insert the arbitrary String. Because we will work on the template XML, the validity of the String to be inserted does not matter. In other words, all the tag groups in the template XML are independent from the values to be inserted.
In case of the input validation, a pair of HTML is required as the source of the conversion, i.e. the tag groups for the invalid case should include the messages (and the additional HTML tags) that ask the user to fix the invalid items and/or to fill the missing items. (For details about the input validation, please read another tutorial) But, in case of the template XML, there is no invalid case. This means the tag groups for the invalid case equal to the ones for the valid case. So, what you need is just a single HTML, not a pair of HTML.
The source of this conversion is the single HTML with the HTML table whose cells are all empty:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta name="Author" content="Jun Inamori firstname.lastname@example.org"> <title>Input validation example 1</title> </head> <body> <h1>Input validation example 1</h1> <p> Thank you. Your information are listed below: <br> <br> <center> <table border="1"> <tr><td>E-mail:</td><td></td></tr> <tr><td>Age:</td><td></td></tr> <tr><td colspan="2" align="center"><a href="Verify">[Try again]</a></td></tr> </table> </center> <br> <br> </p> </body> </html>
Java and all Java-based trademarks and logos are trademarks or registered of Sun Microsystems, Inc. in the United States and other countries.
ALL CONTENTS COPYRIGHT 2005, OOP-Reserch Corporation. All rights reserved.
Any questions and comments are welcome to OOP-Reserch Corporation .