HtmlToXml Tutorial 1: > Conversion from HTML to XML
Previous Page Contents Next Page
OOP-Reserch home page

Contact Us

Conversion from HTML to XML

Conversion from HTML to XML

HtmlToXml converter reads a pair of the normal HTML (or any other mark-up languages, such as XHTML, WML or HDML). The HTML for the valid case will include the tags for the initial CGI FORM. Another one (the HTML for the invalid case) will include the tags for the same CGI FORM along with the error messages (and the additional HTML tags). Please include the error messages (and the additional HTML tags) for case that all the inputs are invalid. For example, the pair of the HTML for the CGI FORM in the previous section will look like:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Input validation example 1</title>
</head>
<body>
<h1>Input validation example 1</h1>
<p>
Hello! Please fill in the CGI FORM below and click <i>Send</i> button.
<br>
<form action="Verify" method="post">
<center>
<table border="1">
<tr>
<td>E-mail:</td>
<td><input type="text" name="email" value=""></td>
</tr>
<tr>
<td>Age:</td>
<td><input type="text" name="age" value=""></td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" name="button" value="Send">
</td></tr>
</table>
</center>
</form>
</p>
</body>
</html>

[HTML for the valid case]



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Input validation example 1</title>
</head>
<body>
<h1>Input validation example 1</h1>
<p>
Hello! Please fill in the CGI FORM below and click <i>Send</i> button.
<br>
<form action="Verify" method="post">
<center>
<table border="1">
<tr>
<td><font color="#ff0000">E-mail. ex)foo@bar.com </font>:</td>
<td><input type="text" name="email" value=""></td>
</tr>
<tr>
<td><font color="#ff0000">Age. Only 0-9 </font>:</td>
<td><input type="text" name="age" value=""></td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" name="button" value="Send">
</td></tr>
</table>
</center>
</form>
</p>
</body>
</html>

[HTML for the invalid case]


As you see, these HTML do not include any fragment related with JSP and custom tag libraries. Only the remarkable point is that the second HTML includes the error messages (and the HTML tags) as if all the inputs are invalid.
Any web designers (or page authors) in the real world can write these HTML in their favorite ways. They do not need to learn even a bit of JSP/JSTL!

As for Localization (L10n), what you need are pairs of the normal HTML, i.e. each pair of the normal HTML will include the localized messages for the intended Locale. Then, based on each pair of HTML, you can generate the XML for each Locale.

In case of WAP service development, what you need is a pair of XHTML, WML or HDML. You need not implement any custom tag libraries for rendering the response for XHTML, WML or HDML.

Once a pair of the HTML is prepared, it's time to work for you (Java programmer). This is the step-by-step tutorial about how to use HtmlToXml converter. Through this tutorial, we will work on the above 2 HTML as an example.

XML Editor : HtmlToXmlEdit...

Once you convert a pair of HTML into the XML, you can edit it by HtmlToXmlEdit. By this the XML editor, you can view/edit each element in the XML, or append/insert the new element into the XML.
Or, it may be the good starting point to walk through the existing XML by HtmlToXmlEdit. Please download your favorite example from our web site and explore the XML in it. Then, you can grasp the whole image of this XML. Anyway, we recommend you also to read through the tutorial of HtmlToXmlEdit before going ahead. (It will not take more than 5 minutes.)

Template XML for dynamic response...

HtmlToXml can also generate the template for the dynamic response. 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 FormGenerator), 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.
For details about how to generate template XML, please read another tutorial.

Java and all Java-based trademarks and logos are trademarks or registered of Sun Microsystems, Inc. in the United States and other countries.


Previous Page Contents Next Page
OOP-Reserch home page

Contact Us


ALL CONTENTS COPYRIGHT 2002, Jun Inamori. All rights reserved.
Any questions and comments are welcome to Jun Inamori .