As a markup language, the widespread use of HTML in the Internet is a testament to its unparalleled usefulness in publishing content. HTML provides a variety of tags to the structure content, including header tags at different levels, such as
I usually use HTML documents to manage information. The use of this kind of page description language is very simple, it is very convenient to store useful data in Web pages-there is no idle document and document loss between the heap, these situations will never appear again. Assuming that more complex HTML documents are ordered (<ol>) or unordered (<ul>), they are typically constructed using a header tag such as
......
3. Configure Proxy Server
......
3.1 Setting up the server
......
3.2 Configuring Agent Rules
......
In some places in the text we can find similar
......
For more information about setting up a proxy server, see Chapter 3.1.
......
Working with diagrams and tables works the same. At this point, the question becomes clear: if something is inserted between existing structures, such as a new chapter 3.1, all subsequent chapter headings must be renumbered. In addition, the reference to the chapter number must also be modified. This is obviously annoying--and worse--prone to errors, particularly if such numbers and references span multiple HTML files that make up the actual document.
Everyday word handlers in your office suite offer another pleasant feature: Automatically create a table of contents or a list of diagrams and tables. In HTML, this list of classes must be created and maintained manually. This is not something we usually enjoy doing.
The Xref tools described in this article provide a simple solution and some additional functionality for these issues. In addition, the tool is a useful example of how to efficiently take advantage of some of the new J2SE 5.0 features.
Of course Xref itself can simplify the creation of HTML content in a variety of ways, with the primary goal of creating a Web authoring area, which creates text that spans one or more HTML documents. The region is supported at several levels of complexity.
In the simplest form of its application, an existing document constructed with an HTML caption tag can be processed, and the title will be automatically numbered. This result is obtained without making any changes. If necessary, all chapters and hyperlink catalogs with points to all chapters can be generated by simply adding a new tag to the document. This is the only necessary change.
In an HTML document, the more complex form of an application requires multiple changes: by adding new HTML tags, additional autonumber is available for other objects such as graphs or tables. Furthermore, the creation of a list (Diagram list or table list) is also supported
The full Xref function is implemented by using the referencing feature. Using another new tag (<ref>) a reference to any tagged object, such as a chapter title, Diagram, or table, can be created within the document and the correct number is inserted in the same position. In addition, hyperlinks to referenced objects are created.
All the source code described in this article and the JAR file with the compiled class can be downloaded-see the Resources section.
Although many popular browsers do not support some of the features described in this article, they can also be implemented on the basis of the counters specified in CSS2 (see the Resources section). These counters can also be used for automatic numbering, such as the automatic numbering of chapter headings. The tools described in this article are more focused on cross-reference tasks and provide several features other than the CSS2 counter:
Items such as diagrams and tables (and other arbitrary sequences) are inserted directly into the document based on the new pseudo HTML tags.
Includes a reference resolution for numbered items (such as chapters or graphs), the creation of a specified anchor for a target, and an automatic cross-reference feature such as a reference to a <a href>.
In the document, includes automatic generation of cross-reference lists, including <a href> references to the referenced items.