Using HTMLDocument to create HTML data
An HTMLDocument functions as a wrapper that holds the information necessary to create either HTML or Extensible Stylesheet Language (XSL) Formatting Object (FO) source data. When you want to create HTML pages, the HTMLDocument class offers you an easier way to group all the required HTML tags.
Generating HTML source data
When creating HTML source, HTMLDocument retrieves HTML tags from the HTML objects you have created. You can use either HTMLDocument.getTag() to stream all the elements you have defined or the getTag() for each individual HTML object.
HTMLDocument generates HTML data as you define it in your Java™ program, so be sure that the resulting HTML is complete and correct.
When you call HTMLDocument.getTag(), the HTMLDocument object performs the following actions:
- Generates the opening <HTML> tag. At the end of the data, it generates the closing </HTML> tag.
- Converts your HTMLHead and HTMLMeta objects into HTML tags.
- Generates the opening <BODY>
tag immediately after the <HEAD>
tag. At the end of the data, just before the closing </HTML> tag,
it generates the closing </BODY> tag.Note: If you do not specify a <HEAD> tag, HTMLDocument generates the <BODY> tag after the <HTML> tag.
- Converts your remaining HTML objects into HTML tags as your program directs.
Examples: Using HTMLDocument
The following example shows how to use HTMLDocument to generate HTML source data (and XSL FO source):
Example: Using HTMLDocument to generate both HTML source and XSL FO source
Javadoc reference documentation
For more information about the HTMLDocument class, see the following Javadoc reference documentation:
HTMLDocument
The following disclaimer applies to all of the IBM® Toolbox for Java examples:
Code example disclaimerIBM grants you a nonexclusive copyright license to use all programming code examples from which you can generate similar function tailored to your own specific needs.
All sample code is provided by IBM for illustrative purposes only. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs.
All programs contained herein are provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.