The structure of an SPS document is both input- as well as output-driven, and it is controlled by:
Input-driven structure: schemas and modular SPS files
By input-driven, we mean that the source schemas of SPS files specify the structure of the input document/s and that this structure is the structure on which the SPS document is based. For example, if a source schema specifies a structure that is a sequence of Office elements, then SPS design could have a template for the Office element. At processing time this template will be applied in turn to each Office element in the source data document.
Another example of how the source document structure drives the design of the SPS file can be seen in the use of tables. Say that an Office element contains multiple Person element children, and that each Person element contains a set of child elements such as Name, Address, Telephone, etc. Then a template in the form of a table can be created for the Person element. Each Person element can be presented in a separate row of the table (screenshot below), in which the columns are the details of the Person (the child elements of the Person element).
Such a template is possible because of the structure of the Person element and because the Person elements are siblings. In the table template a single row is designed for the Person element, and this processing (the row design) is applied in turn to each Person element in the source document, creating a new row for each Person element, with the child elements forming the columns of the table.
How to use various kinds of schema sources is described in the section, Schema Sources.
Additionally, StyleVision allows SPSs to be re-used as modules within other SPSs. In this way, modules can be included within a structure and can modify it. However, a schema structure contained in a module must fit in with the structure of the underlying schema of the containing SPS. How to work with modular SPSs is described in the section, Modular SPSs.
Output-driven structure: templates and design fragments
While the schema sources provide the structure of the input data document, the actual design of the output document is what is specified in the SPS document. This design is contained in one document template called the main template. The main template typically contains several component templates and can reference global templates. Templates are described in the section, Templates and Design Fragments.
This composability (of multiple templates) is further enhanced by a StyleVision feature called Design Fragments, which enables specific processing to be assigned to a document fragment that can be re-used. A Design Fragment is different than a global template in that: (i) it can be composed of multiple templates; and (ii) identical content with different processing can be created in separate design fragments, either of which can be used in a template according to the situation. For example, in some processing situations, an Email node might be required as a link that opens an empty email; in other cases the Email element could be required in bold and in red. Two separate design fragments could provide the respective processing, and both can be re-used as required.
Design fragments are described in detail in the section, Design Fragments.