Elements to style

To gain a list of all the elements that may occur in a compliant document, it is simply necessary to read the names appearing after the ELEMENT declarations. In the following example, the DTD defines just four elements, called 'Book', 'Title', 'Chapter' and 'Para':

<!ELEMENT Book    (Title, Chapter*)>
<!ELEMENT Title   (#PCDATA)>
<!ELEMENT Chapter (Title, Para*)>
<!ELEMENT Para    (#PCDATA)>

The following is a conforming document instance:

<Book>
  <Title>The Book Title</Title>
  <Chapter>
    <Title>Chapter One Title</Title>
    <Para>First paragraph.</Para>
    <Para>Second paragraph.</Para>
  </Chapter>
  <Chapter>
    <Title>Chapter Two Title</Title>
    <Para>First paragraph.</Para>
    <Para>Second paragraph.</Para>
  </Chapter>
</Book

A template could be created for each of these elements.

<template match="Book">...</template>


<template match="Title">...</template>


<template match="Chapter">...</template>


<template match="Para">...</template>

However, it is usually necessary to study the possible content of the element to determine the role each element plays. Several templates, or perhaps no templates, may actually be necessary for a given element. In some cases, an element may not play any direct role in the styling of its content. In the example above, the Chapter element may not need to be processed (though its presence can be useful in creating context-sensitive styles for other elements). In other cases, more than one template may be needed for a given element. In the example above, the Title element may be used to give the whole book a name, and to give each chapter a name, and it is not likely that these two classes of title are to be styled in the same way.

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

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