This package provides base classes for generating markup, presumably XML but not limited to it. It also provides a flexible CSS classes usable for both stylesheets and 'style=' attributes.

The abstract Tag class contains all the equipment necessary to create, manage, and output an XML tag. Any XML tag. Its protected constructor accepts a String argument for the name of the tag and it maintains an internal Hashtable for attributes. The actual name of the tag is kept as a protected field, accessible to any subclass. Tag does not itself maintain content, since that could be complex, but it instead defines the protected methods _content() and _setContent(), which return String and accept one, respectively. In this way Tag gives its subclass complete content control: the _content() method is not called until absolutely necessary, and whatever it returns is processed into the final (String) XML tag. If the method returns null an empty tag is generated.

The _setContent() method is used for two purposes: copying and clearing. The _enableCopy() method causes the current content and attributes to be saved into temporary static variables. The very next time a Tag or subclass is instantiated it receives a copy of the content and attributes stored. Once. The attribute Hashtable is handled automatically but content is passed via _setContent(). It is assumed that any class defining the method knows how to parse whatever content it needs from a single String. The second use is in the reset() method. When this method is called on Tag it clears the currently-set attributes and then calls _setContent(null).

Besides these two methods, Tag has static factory methods for creating an XML opening tag, complete with name and attributes, a closing tag, and a complete set. Calling makeTag() with a String name, Hashtable attributes and a String for content causes the creation of an opening tag and, if the content String is not null or empty, a closing tag both wrapped around the content. If the content is null or blank an empty opening tag is returned. This is similar to MathXML.wrapTag() but much, much more featureful. The toString() (instance) method makes use of all of these; it produces a well-formed XML tag or tag pair. If the tag is to be the root of a document, _setEnableXMLTag(true) causes the initial <?xml ... ?> declaration to be prepended before the opening tag.

The StyleInfo class provides basic structure and equipment for the manufacture of CSS rules. It handles declarations via an internal Hashtable and can print them raw (toString()), as a full attribute (enclosed in quotes with an optional rule name), or as a CSS rule (name, space, then declarations space-and-semicolon-separated and the body of the rule enclosed in curly braces). Extending StyleInfo allows sensible setters for whatever declarations are allowed for a particular markup. Further, since the method to set a declaration is protected it allows filtering of declarations that should not be present. The SimpleStyleImpl extends StyleInfo and makes public the methods to set declarations and to access a copy of the declarations, so it is usable as-is to create any CSS rule with no restrictions on anything.

SimpleTagImpl provides a concrete subclass of Tag and adds low-level XML tag-construction capability. It is exposed to scripts as 'SimpleTag' and can be instantiated alone or around a tag name. The tag name can be set or cleared and an instance method is provided to shadow all of Tag's static ones. Content is implemented via a StringBuffer which can be set, cleared, and added to. A method to create a SimpleStyleImpl instance completes the toolkit. Any XML tag can be constructed from scratch.

Along Came LaTeX

The latex.* package provides support for the mathematical typesetting language LaTeX. It is an open standard backed by tons of open-source software for all operating systems. The MathTools LaTeX package is minimalistic in nature: it provides only enough LaTeX to generate tests and worksheets. That is not to say it can't be extended, or will not be, but the intent is for a 'just enough' implementation.

LaTeX is not XML markup. It does not make use of the Tag class, CSS or any other XML. Its base class is LaBaseTag and it resides within the subpackage.