





















































{literal}As more and more features get added to your software, the Help system for the software becomes extensive. It could probably contains hundreds of HTML files plus a similar number of images. We could always face the problems listed below.
Another problem could occur when the user does a free text search of the help system. The result of such a search is a list of files, each represented by its title. In our system, documents could have the title "untitled".
In fact, the JavaHelp 2.0 System User's Guide contains the recommendation
"To avoid confusion, ensure that the <TITLE> tag corresponds to the title used in the table of contents."
Given that customers mostly use the Help system when they are already frustrated by our software, we should always see to it that such errors do not exist in our help system. To do this, we will write a tool, HelpGenerator, that generates some of the boilerplate XML in the help system and checks the HTML and index files for the problems listed above. We will also build tools for displaying and testing the contextual help. We've re-engineered and improved these tools and present them in this article.
In this article we are assuming familiarity with the JavaHelp system. Documentation and sample code for JavaHelp can be found at: http://java.sun.com/products/javahelp.
A JavaHelp package consists of:
<index version="1.0">
<indexitem text="This is an example topic."target="Topic">
<indexitem text="This is an sub-topic."target="SubTopic"/>
</indexitem>
</index>
<map version="1.0">
<mapID target="Topic" url="Topic.html"/>
<mapID target="SubTopic" url="SubTopic.html"/>
</map>
Our software will normally have a main menu item to activate the Help and, in addition, buttons or menu items on specific dialogs to activate a Help page for a particular topic, that is, "context-sensitive" Help.
At an overall structural level, we need to check:
At a lower level, we need to check the contents of each of the HTML files:
Finally, we need to check that the contents of the files and the indexes are consistent
To simplify these tests, we will follow a simple naming pattern as follows:
We adopt the convention that the name of each HTML file should be in CamelCase format (conventional Java class name format) plus the .html extension. Also, we use this name, without the extension, as the target name. For example, the target named SubTopic will correspond to the file SubTopic.html.
Furthermore, we assume that there is a single Java package containing all the required help files, namely, the HTML files, the image files, the index file, and the map file. Finally, we assume a fixed location for the Help search database.
With this convention, we can now write a program that:
The class HelpGenerator in the package jet.testtools.help does all this,and, if there are no inconsistencies found, it generates the map file. If an inconsistency or other error is found, an assertion will be raised. HelpGenerator also performs the consistency checks at the level of individual HTML files. Let's look at some examples.
Here is a simple help system with just three HTML files:
The index file, HelpIndex.xml, only lists two of the HTML files:
<index version="1.0">
<indexitem text="This is an example topic."
target="ExampleTopic">
<indexitem text="This is an example sub-topic."
target="ExampleSubTopic"/>
</indexitem>
</index>
When we run HelpGenerator over this system (we'll see how to do this later in this article), we get an assertion with the error message
The Help file: TopicWithoutTarget.html was not referenced in the Index file: HelpIndex.xml.