== Motivation == For conversion purposes there is a need to be several data models. Defining data models help factoring document analysis and preparation code out of individual converters and also act as contract. A converter is complete when it can properly convert any document conforming to a chosen data model. The main design goal is to make the life easier to converter programmers. Arbitrary TeXmacs documents are difficult to process because the typesetter is very lenient on the output it accepts. More constrained data models must always be *simpler* from a programmer perspective. To achieve that goal all data models define documents which can be processed by the typesetter. == Main data models == The Internal data model includes any document which can be processed by the typesetter in finite time and without crashing. There is a few simple ways to crash the typesetter by providing invalid data. All other data models are subsets of the Internal data model. The Structural data model restricts allowed constructs to what do not require an elaborate evaluation system. A conforming document can be exported to a convenient XML representation. A non-conforming document cannot generally be converted automatically while conserving the structural information. The Valid data model introduces contextual constraints on the use of primitives and standard markup. A conforming document can be exported without essential structural modifications or loss of information. A Structural document can be made Valid by a non-interactive program, but that may require some significant changes in the structure. The Normalized data models puts additional constraints on the presence or the location of some elements to make the life easier to programmers. Different conversion tools may have different normalization requirements. Conversion to highly normalized models may be destructive of essential informations (e.g. index markup may be converted to simple labels, float may be transformed to static objects). == Structural data model == (with { }+ ) : typesetter variable name as a string. : legal value for the typesetter variable, as a string. (apply *): must be a string. (expand *): must be a string. (label ) (reference ) (pageref ) (hlink ): must be a string (postscript ...): cropping and included graphics are forbidden. Math elements are allowed only in specific structures. Deprecated elements are forbidden. Elements which are used to design stylesheets are forbidden. Unimplemented elements are forbidden. == Valid data model == (x) denotes a structure (a Scheme list). { } denotes a group for |, *, + and ?. {{ }} denotes a group which is wrapped in a concat if it contains multiple items or occurs multiple times. A valid document may or may not be concat-simplified. {{{ }}} denotes a group which is wrapped in a document if it contains multiple items or occurs multiple times. ::= (document +) ::= | | | | ::= (with { }+ ) ::= | ::= (paragraph +) | ::= {{ | | | |