Templates and content

The root element of an XSL document is actually called Root. This element contains two major sections. First, templates are defined that specify the characteristics of the pages to display or print, including the size of these pages. More than one page template may be defined (for example, this book requires a different template for the preliminary pages than for the chapters, and the first page of each chapter differs from the remainder). The Layout Master Set element contains these templates:

					<root>
					<layout-master-set>
    <!-- TEMPLATES -->
  </layout-master-set>

  <!-- CONTENT -->
</root>
				

Some templates may have header and footer regions, and the even-numbered pages may differ from the odd-numbered pages (as they do in this book). The Simple Page Master element is used to define each template, and so it may occur several times within the Layout Master Set element:

<root>
  <layout-master-set>
    <simple-page-master ...>
    <!-- TEMPLATE 1 -->
    </simple-page-master>
    <simple-page-master ...>
    <!-- TEMPLATE 2 -->
    </simple-page-master>
  </layout-master-set>
  ...
</root>

After the templates, the actual information to present is stored, including embedded formatting tags. This information may be divided into sections that will use different templates, or combinations of templates (there would be a separate section for each chapter of this book), and each section must therefore be linked to a specific template, or template combination. The Page Sequence element holds the content to associate with a particular template. It has a Master Name attribute to identify the template it is associated with. The Simple Page Master element has the same attribute, and so the two are linked by having identical values in these attributes:

<root>
  <layout-master-set>
    <simple-page-master master-name="Prelims">
    <!-- TEMPLATE 1 -->
    </simple-page-master>
    <simple-page-master master-name="MainContent">
    <!-- TEMPLATE 2 -->
    </simple-page-master>
  </layout-master-set>


  <page-sequence master-name="Prelims">
    <!-- CONTENT 1 -->
  </page-sequence>
  <page-sequence master-name="MainContent">
    <!-- CONTENT 2 -->
  </page-sequence>
</root>

Pages are created by selecting an appropriate template, and 'flowing' the content into areas that follow the page template rules. If there is too much content to fit the page, another page may be generated from the template, and the content then continues to flow into the new page. For example, in this book the number of actual pages produced varies for each chapter, depending on how much there is to say on each topic. But this can be prevented. For example, the first page of each chapter always uses a distinct template (this template is used for the content placed on the first page, but not subsequent pages).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset