Style handling design in SimplyHTML

Java implements class StyleSheet to define central styles in CSS notation for an HTMLDocument. In addition styles in CSS syntax can be included directly in HTMLDocuments by storing them as an attribute to a HTML tag.

In all Java versions up to J2SE 1.4 there is no way however, to store styles persistently although working with HTMLDocuments in Java would hardly work without styles. Applications creating HTMLDocuments have to find a way to save styles on their own. SimplyHTML defines and uses an own class CSSWriter for this matter.

When are styles saved?

In stage 1 of application SimplyHTML styles can not be changed, so a style sheet is only saved, when a newly created document is saved (i.e. the document was not loaded from a file and a style sheet with the same name does not exist at the target location for the document).

This leaves one conflict open:

- a style sheet exists at the location where a new document is to be saved and
- the exisiting style sheet has the same name as the style sheet associated with the new document to be saved and
- the exisiting style sheet is different from the style sheet associated with the new document

In this case, the style sheet is not saved and the existing style sheet is used. A solution for this case is not implemented in SimplyHTML yet. A workaround for the time being is to save newly created documents in a directory which holds only documents sharing the default style sheet of SimplyHTML.

In later stages of SimplyHTML it will be possible to change styles. Then the association of style sheets and documents as well as the handling of saving style sheets will be refined.