Techniques for forming a document model for constructing a semantically
and syntactically valid document are provided. In one embodiment, a
method for forming a document model for constructing a semantically and
syntactically valid document includes the steps of: creating a root tag
element corresponding to a root of the document to be constructed, the
root tag element including information relating to a corresponding tag;
associating one or more model elements with the root tag element, each
model element representing an alternative to the information relating to
the corresponding tag; and for each of the model elements, creating a
syntactically and semantically valid sub-tree of elements based at least
in part upon a structure of the document to be constructed under one or
more predetermined conditions.