previous   next   contents  

13. SMIL 3.0 External Timing

Editors for SMIL 3.0:
Petri Vuorimaa, TKK
Dick Bulterman, CWI

Table of contents

13.1 Summary of Changes for SMIL 3.0

This section is informative

This module defines new functionality for SMIL 3.0. It extends SMIL timing allowing integration of timing into a wide range of other XML languages, but does not alter any other existing functionality from SMIL 2.1 or earlier versions.

13.2 Introduction

This section is informative

This module defines an XML timing language that makes SMIL 3.0 element and attribute timing control available to a wide range of other XML languages. This language allows SMIL timing to be integrated into a wide variety of a-temporal languages, even when several such languages are combined in a compound document. Because of its similarity with external style and positioning descriptions in the Cascading Style Sheet (CSS) language, this functionality has been termed SMIL Timesheets.

Timesheets allows the definition of out-of-line timing in conjunction with non-SMIL languages including compound XML documents. To make authoring easier, it contains only a limited subset of SMIL functionality. An alternative to Timesheets is XHTML+SMIL, which gives full SMIL functionality as in-line in non-SMIL XML documents. Finally, SMIL itself gives full SMIL functionality as in-line SMIL XML.

SMIL Timesheets can be seen as a temporal counterpart of CSS. Whereas CSS defines the spatial layout of the document and formatting of the elements, SMIL Timesheets specify which elements are active at a certain moment and what their temporal scope is within a document. And as with CSS, SMIL Timesheets can be reused in multiple documents, which can provide a common temporal framework for multimedia presentations with different contents but identical storylines. The document can be shown in a user agent even if SMIL Timesheets are not supported, since the contents and the layout are still governed by the document itself. Of course, the temporal aspect of the document is then lost, since all the elements are active all the time.

The SMIL 3.0 External Timing module is based on the SMIL 3.0 Timing and Synchronization modules with some restrictions and additional attributes. In addition, it includes the SMIL 3.0 PrefetchControl module. Also, the SMIL 3.0 BasicAnimation module is used for controlling animations. In addition, SMIL Timesheets uses CSS selectors [CSS2]. Finally, the SMIL 3.0 External Timing module defines two new elements timesheet and item.

First, an overview of the SMIL Timesheets is given in the Overview section. After that, the new elements timesheet and item and use of CSS selectors are described in the SMIL Timesheet Specific Elements section. Then, the use of SMIL 3.0 Timing and Synchronization modules is discussed in the Timing and Synchronization section. After that, the Prefetch section describes how the SMIL 3.0 PrefetchControl is used. Next, Animation section covers the use of SMIL 3.0 BasicAnimation module. Description of the event model and examples on how events can be used in SMIL Timesheets is given in the Event Model section. Finally, integration with CSS layout is discussed in the Integration with CSS Layout section.

13.3 Overview

This section is informative

The following example is a simple slide show. The SMIL Timesheet is located in the head section. It is declared with timesheet element, which belongs to the smil namespace. In this example, the seq element is used for timing. The item elements contain references to the body of the document and additional timing information. The elements of the document body are selected using CSS selectors. In this example, the id selectors (i.e., "#Slide1", "#Slide2", and "#Slide3") are used. Based on the timing information a new slide is shown after five seconds.

<!DOCTYPE htmlLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:smil="http://www.w3.org/2007/07/SMIL30/Timesheets">

  <head>
    <smil:timesheet>
      <seq>
        <item select="#Slide1" dur="5s" />
        <item select="#Slide2" dur="5s" />
        <item select="#Slide3" dur="5s" />
      </seq>
    </smil:timesheet>
  </head>

  <body>
    <div id ="Slide1" class="Slide">
      <h1 id="Title1">Timesheets</h1>
      <ul>
        <li id="Bullet1_1" class="Bullet">Timesheets defines temporal dimension of documents</li>
        <li id="Bullet1_2" class="Bullet">Timesheets uses SMIL Timing and Synchronization primitives</li>
        <li id="Bullet1_3" class="Bullet">Timesheet is located in the head section of the document</li>
        <li id="Bullet1_4" class="Bullet">The body elements are selected using CSS selectors</li>
      </ul>
    </div>
    <div id ="Slide2" class="Slide">
      <h1 id="Title2">CSS Selectors</h1>
      <ul>
        <li id="Bullet2_1" class="Bullet">Timesheets uses CSS selectors to reference body elements</li>
        <li id="Bullet2_2" class="Bullet">Id selector references individual elementst</li>
        <li id="Bullet2_3" class="Bullet">Other selectors can be used to match multiple elements</li>
        <li id="Bullet2_4" class="Bullet">For example, class selector matches all elements that belong to certain class</li>
      </ul>
    </div>
    <div id ="Slide3" class="Slide">
      <h1 id="Title3">Animations</h1>
      <ul>
        <li id="Bullet3_1" class="Bullet">Timesheets includes also BasicAnimation module</li>
        <li id="Bullet3_2" class="Bullet">Supported elements are animate, set, animateMotion, and animateColor</li>
        <li id="Bullet3_3" class="Bullet">The animation can be defined with either values or from, to, and by attributes</li>
        <li id="Bullet3_4" class="Bullet">The target elements are referenced with CSS selectors</li>
      </ul>
    </div>
  </body>
</html>

13.4 SMIL Timesheet Specific Elements

This section is informative.

This section defines the new timesheet and item elements and their attributes.

13.4.1 The timesheet element

This section is normative.

The timesheet element is located in the head section of the document. It defines a parent container for other SMIL Timesheet elements.

Element Attributes

This section is informative.

The timesheet element defines two attributes: src and media.

The src Attribute

This section is normative.

The src attribute tells the location of an external timesheet, which will be appended to the end of the local timesheet. With this attribute a common timesheet can be reused in multiple documents. The attribute must contain a valid URI.

The media Attribute

This section is normative.

The media attribute is used for selecting the most suitable timesheet for current media device. It works similarily to the @media rule in the CSS stylesheets [CSS2].

Element Content

This section is normative.

The timesheet element contains the par, seq, and excl time containers. In addtion, it contains all the item and prefetch elements. Finally, it also contains the animation elements: animate, set, animateMotion, and animateColor.

13.4.2 The item element

This section is normative.

The item target element references elements in the document host language(s). The item element implements the actual connection between the timesheet and the document. It can reference a media element or a set of elements by the element's tag, id or class; the syntax and processing is similar to the CSS selector [CSS2] syntax.

The CSS selector can match more than one element in the document body, for example, when CSS class selector is used. In that case, all matching elements are selected. Thus, one item element can reference multiple body elements at the same time. In practise, this is the same as referencing the selected body elements with individual ID selectors element by element.


This section is informative.

The following example illustrates how the CSS class selector can be used to select more than one slides at the same time.

<smil:timesheet>
  <seq>
    <item select=".Slide" dur="5s"/>
  </seq>
</smil:timesheet>

The class selector ".Slide" selects all the slides at once. Thus, the above timesheet is equivalent to the first example.

Element Attributes

This section is informative.

The item element defines three attributes: select, beginInc, and indexStart. In addtion, it used the begin, dur, end, repeatCount, and repeatDur attributes defined in the SMIL 3.0 Timing and Synchronization module.

The select Attribute

This section is normative.

The select attribute links the timesheet to the document. The attribute follows the same syntax and processing as the CSS selectors [CSS2], so that the elements can be referenced by their name, id or class, or a more complex combination of the selectors. If the attribute targets multiple elements in the document, item controls all of them. The attribute value can also specify a comma separated list of selectors.

The prefetch Attribute
The beginInc Attribute

This section is normative.

The beginInc attribute increments the begin time by the defined value when the selector matches more than one element.


This section is informative.

The following example illustrates how the beginInc can be used to increment the starting times of individual elements.

<par>
  <item select=".Bullet" beginInc="1s" />
</par>
 

In practise, the above example could also be expressed as follows.

<par>
  <item select="#Bullet1_1" begin="0s" />
  <item select="#Bullet1_2" begin="1s" />
  <item select="#Bullet1_3" begin="2s" />
  <item select="#Bullet1_4" begin="3s" />
</par>
 
The indexStart Attribute

This section is normative.

The indexStart attribute can be used to change the starting value of the index() function. The default value of indexStart attribute is 0, and thus the index() function starts to count the found item elements from index number 0. IndexStart attribute can be given positive integer value to change the starting value of the index() function to the given value. An example of how IndexStart attribute can be used is given in the Event Model section, which describes a use case of the index() function.

Element Functions

This section is informative.

The item element defines one function index(), which can be used to automatically generate index numbers for both internal and external events within begin, dur, or end attributes of the item element.

The Index Function

This section is normative.

The index() function can be used to automatically generate index numbers for both internal and external events within begin, dur, or end attributes of the item element. If these attributes contain the index() function, it must be replaced with the given parameter and the current index number of the matched item. The index number starts from 0 and counts upwards. The starting number can be changed to some other positive integer number with the indexStart attribute. An example how the index() function can be used is given later in the Event Model section.

Element Content

This section is normative.

The item element can contain time containers seq, par, and excl, prefetch elements, and other item elements. However, the direct child of the item element must be either the seq, par, and excl time container or none. Other descendant item elements can only be included within the child seq, par, and excl time containers. Furthermore, the parent item element limits the scope of the CSS selectors of the child item elements to match only descendant elements of the elements selected by the parent item element.


This section is informative.

In the following example, an item element contains seq time container and further another item element.

<smil:timesheet>
  <seq>
    <item select=".Slide" dur="7s">
      <seq>
        <item select=".Bullet" dur="1s" />
      </seq>
    </item>
  </seq>
</smil:timesheet>

The parent item element selects one slide at a time and shows each slide for 7 seconds. Within each slide the child item element selects each bullet and shows it for 1 second.

13.5 Timing and Synchronization

This section is informative.

The SMIL 3.0 External Timing module uses four SMIL 3.0 Timing and Synchronization modules:

  1. BasicInlineTiming
  2. EventTiming
  3. BasicTimeContainers
  4. BasicExclTimeContainers
  5. RepeatTiming

This section gives futher details on the attributes and elements of the above mentioned modules. The reader is presumed to have read and be familiar with them.

The timing semantics of the timesheets is based on the semantics of the SMIL 3.0 Timing and Synchronization chapter, although it has been simplified a bit. This may cause the timing model not to be as powerful in expressing timing relations as SMIL's, but it should be more approachable to the authors.

The base time, or the syncbase of a timesheet element is the moment when the element is activated by its parent. Activating an element doesn't necessarily make the referenced media element visible. Rather, it sets the time moment "0s", to which the element's attributes are compared.

The syncbase of the child elements of a time container is dependent on the type of the container. The children of par and excl elements have the starting time of their parent as their syncbase. The children of the seq element consider the end time of preceding child as their syncbase. This time is resolved only at the moment the preceding child ends.

Figure 1 shows a simple example of the semantics of a timesheet. A parallel time container has two children, which are item elements referencing two media elements. When the par is started, it activates both its children with the current time as their syncbase. The media elements referenced by the children are not activated yet. At time moment 1s, the media element item1 is activated, according to the begin value of the referencing timesheet element. At 2s, the item2 is activated. At 3s, the duration of item1 runs out, so it is stopped and the corresponding timesheet element deactivates itself. At 4s, the parent container stops according to its duration attribute, stopping all of its active children.

Time semantics

Figure 1: Timeline of a Timesheets

The duration of an element is primarily defined by the dur attribute. If the element is not stopped prematurely, due to an event or scheduling of its parent, the dur attribute tells the overall duration of the element. The element will not stop until this duration has passed, and will not stay active longer than this duration. The value of the dur attribute will prevail:

If the duration is not set, the duration of an element depends on the type of the referenced elements, or the durations of the children. The timesheet items can reference to discrete and continuous elements in the document. Discrete elements don't have implicit durations, and the implicit duration of an item element referencing a discrete element is "indefinite". Continuous elements have their own durations, which will be also used as the duration of the timesheet element. The duration of the timecontainer depends on the durations and activations of its children. The seq and par elements stay active until all of their children have stopped. The implicit duration of the excl is always "indefinite".

13.5.1 Attributes

This section is informative.

The SMIL 3.0 External Timing module includes the basic timing attributes begin, dur, and end as defined in the BasicInlineTiming and EventTiming modules. In addtion fill and endsync attributes are included as defined in the BasicTimeContainers and BasicExclTimeContainers modules. Also, it includes the repeatCount and repeatDur attributes as defined in the RepeatTiming module. The rest of the SMIL 3.0 Timing and Synchronization attributes are not supported. Finally, the SMIL 3.0 External Timing module includes four new Timing and Synchronization attributes: first, prev, next, and last.

The begin Attribute

This section is normative.

The begin attribute supports offset and event values, and "indefinite". All other values are not supported. The begin attribute is defined in the SMIL 3.0 Timing and Synchronization module.

The dur Attribute

This section is normative.

The dur attribute supports the clock values, "media", and "indefinete". The dur attribute is defined in the SMIL 3.0 Timing and Synchronization module.

The end Attribute

This section is normative.

The end attribute supports offset and event values, and "indefinite". All other values are not supported. The end attribute is defined in the SMIL 3.0 Timing and Synchronization module.

The fill Attribute

This section is normative.

The fill attribute allows an author to specify that an element should be extended beyond the active duration by freezing the final state of the element. It is defined in the SMIL 3.0 Timing and Synchronization module. Since SMIL 3.0 External Timing module does not include transitions, the fill="transition" value of fill attribute is not supported. Also, since the fillDefault attribute is not included in the SMIL 3.0 External Timing module, the fill="default" is interpreted the same as fill="auto".

The endsync Attribute

This section is normative.

The endsync attribute controls the implicit duration of time containers, as a function of their children. It is defined in the SMIL 3.0 Timing and Synchronization module.

The repeatCount Attribute

This section is normative.

The repeatCount attribute specifies the number of iterations of a simple duration. It is defined in the SMIL 3.0 Timing and Synchronization module.

The repeatDur Attribute

This section is normative.

The repeatDur attribute specifies the total duration for repeat. It is defined in the SMIL 3.0 Timing and Synchronization module.

The first Attribute

This section is normative.

The first attribute sets the current active child of a time container "inactive". Then, it selects the first child element and sets it "active".

The prev Attribute

This section is normative.

The prev attribute first checks, whether the current active child is the first child. If not, it sets the current active child of a time container "inactive". Then, it selects the previous child of the time container and sets it "active".

The next Attribute

This section is normative.

The next attribute first checks, whether the current active child is the last child. If not, it sets the current active child of a time container "inactive". Then, it selects the next child of the time container and sets it "active".

The last Attribute

This section is normative.

The last attribute sets the current active child of a time container "inactive". Then, it selects the last child of the time container and sets it "active".

13.5.2 Elements

This section is informative.

The SMIL 3.0 External Timing module includes three elements par, seq, and excl as defined in the BasicTimeContainers and BasicExclTimeContainers modules.

The par Element

This section is normative.

The par element is defined in the SMIL 3.0 Timing and Synchronization module.

The seq Element

This section is normative.

The seq element is defined in the SMIL 3.0 Timing and Synchronization module.

There are also four additional attributes that are specified for the seq element. They are first, prev, next, and last. These are used to select a certain child of the seq element, which facilitates the creation of presentations where the user can have control of the progression of the timeline, for example, a slide show.


This section is informative.

The following example illustrates how the additional first, prev, next, and last attributes can be used in slideshow. It contains a new timesheet and four buttons, which are appended to the body part of first example.

<head>
  <smil:timesheet>
    <seq first="first.DOMActivate" prev="prev.DOMActivate" next="next.DOMActivate" last="last.DOMActivate">
      <item select=".Slide" />
    </seq>
  </smil:timesheet>
</head>

<body>
  ...
  <button id="first">First slide</button>
  <button id="prev">Previous slide</button>
  <button id="next">Next slide</button>
  <button id="last">Last slide</button>
</body>

The first button selects the first slide, the prev button selects the previous slide, the next button selects the next slide, and finally the last button selects the last slide.

The excl Element

This section is normative.

The excl element is a simplified version of the excl element defined in the SMIL 3.0 Timing and Synchronization module, since the SMIL 3.0 External Timing Module does not include the BasicPriorityClassContainers module.

There are also four additional attributes that are specified for the excl element. They are first, prev, next, and last. These are used to select a certain child of the excl element, which facilitates the creation of presentations where the user can have control of the progression of the presentation, for example, a picture show.

13.6 Prefetch

This section is informative.

The SMIL 3.0 External Timing module uses the SMIL 3.0 PrefetchControl module. The module defines one element prefetch, which has three attributes mediaSize, mediaTime, and bandwidth. This section gives further details on how the attributes and elements of the SMIL 3.0 PrefetchControl module are used in Timesheets. The reader is presumed to have read the SMIL 3.0 PrefetchControl module and be familiar with it.

13.6.1 Attributes

This section is normative.

The SMIL 3.0 External Timing module includes all three attributes of the SMIL 3.0 PrefetchControl module: mediaSize, mediaTime, and bandwidth.

The mediaSize Attribute

This section is normative.

The meadiaSize attribute defines how much of the resource to fetch as a function of the file size of the resource. It is defined in the SMIL 3.0 PrefetchControl module.

The mediaTime Attribute

This section is normative.

The meadiaTime attribute defines how much of the resource to fetch as a function of the duration of the resource. It is defined in the SMIL 3.0 PrefetchControl module.

The bandwidth Attribute

This section is normative.

The bandwidth attribute defines how much network bandwidth the user agent should use when doing the prefetch. It is defined in the SMIL 3.0 PrefetchControl module.

13.6.2 Elements

This section is normative.

The SMIL 3.0 External Timing module includes the prefetch element of the SMIL 3.0 PrefetchControl module.

The prefetch Element

This section is normative.

The prefetch element gives authoring tools or savvy authors the ability to schedule retrieval of resources when they think that there is available bandwidth or time to do it. It is defined in the SMIL 3.0 PrefetchControl module. It uses the mediaSize, mediaTime, and bandwidth attributes.

13.7 Animation

This section is informative.

The SMIL 3.0 External Timing module uses the SMIL 3.0 BasicAnimation module. This section gives further details on how the attributes and elements of the SMIL 3.0 BasicAnimation module are used in Timesheets. The reader is presumed to have read the SMIL 3.0 BasicAnimation module and be familiar with it.

13.7.1 Attributes

This section is informative.

In SMIL 3.0 BasicAnimation module, the animation target element can be referenced either with targetElement or XLink href attribute. According to the module, a host language designer should select only one of them. In Timesheets, the href is more natural choice. However, use of wider selection of CSS selectors is prefered as in the item element. Therefore, the select attribute is used instead of targetElement and href attributes. Because of this choise, the XLink actuate, show, and type attributes are also not used.


This section is normative.

Timesheets uses the select attribute to specify the target element. Therefore is does not include the targetElement and the XLink attributes href, actuate, show, and type attributes. The target attribute is specified with the attributeName attribute and optional attributeType attribute, which specifies whether the target attribute is CSS property or XML attribute. Animation is described either as a list of values, or in a simplified form that describes the from, to, and by values. The calcMode attribute specifies the interpolation mode for the animation. The cumulative and additive behavior of repeating animations is controlled with the accumulate and additive attributes, respectively. The origin attribute specifies the origin of motion for the animation. Finally, begin, dur, end, and fill attributes are used to control the timing of animation, while repeatCount and repeatDur attributes are used to control the repeat of animation.

The select attribute is described in the SMIL Timesheet Specific Elements section, while the begin, dur, end, fill, repeatCount, and repeatDur attributes are described in the Timing and Synchronization section. The other animation attributes are described below.

The attributeName Attribute

This section is normative.

The attributeName attribute specifies the name of the target attribute. It is defined in the SMIL 3.0 BasicAnimation module.

The attributeType Attribute

This section is normative.

The attributeType attribute specifies the namespace in which the target attribute and its associated values are defined. It is defined in the SMIL 3.0 BasicAnimation module.

The values Attribute

This section is normative.

The values attribute contains a semicolon-separated list of one or more values. It is defined in the SMIL 3.0 BasicAnimation module.

The from Attribute

This section is normative.

The from attribute specifies the starting value of the animation. It is defined in the SMIL 3.0 BasicAnimation module.

The to Attribute

This section is normative.

The to attribute specifies the ending value of the animation. It is defined in the SMIL 3.0 BasicAnimation module.

The by Attribute

This section is normative.

The by attribute Specifies a relative offset value for the animation. It is defined in the SMIL 3.0 BasicAnimation module.

The calcMode Attribute

This section is normative.

The calcMode attribute specifies the interpolation mode for the animation. It is defined in the SMIL 3.0 BasicAnimation module.

The accumulate Attribute

This section is normative.

The accumulate attribute controls whether or not the animation is cumulative. It is defined in the SMIL 3.0 BasicAnimation module.

The additive Attribute

This section is normative.

The additive attribute controls whether or not the animation is additive. It is defined in the SMIL 3.0 BasicAnimation module.

The origin Attribute

This section is normative.

The origin attribute specifies the origin of motion for the animation. It is defined in the SMIL 3.0 BasicAnimation module.

13.7.2 Elements

This section is normative.

The SMIL 3.0 External Timing module includes all elements of the SMIL 3.0 BasicAnimation module: animate, set, animateMotion, and animateColor.

The animate Element

This section is normative.

The animate element controls the animation of both CSS properties and XML element attributes. It is defined in the SMIL 3.0 BasicAnimation module. It uses the select, from, to, by, values, calcMode, accumulate, additive, begin, dur, end, fill, repeatCount, and repeatDur attributes.


This section is informative.

The following example illustrates how the animate element can be used to animate CSS attributes of elements of the host language.

<smil:timesheet>
  <seq>
    <item select=".Slide" dur="15s">
      <par>
        <item select=".Bullet" beginInc="3s">
          <animate select=".Bullet" attributeName="marginLeft" values="200;0" dur="1s" />
        </item>
      </par>
    </item>
  </seq>
</smil:timesheet>

The slides are shown in sequential order, while the bullets are shown in parallel within each slide. However, each bullet starts 3 seconds after the previous one. Each bullet flies from right to left for 1 second when shown.

The set Element

This section is normative.

The set element provides a simple means of setting the value of an attribute for a specified duration. It is defined in the SMIL 3.0 BasicAnimation module. It uses the select, to, begin, dur, end, fill, repeatCount, and repeatDur attributes.

The animateMotion Element

This section is normative.

The animateMotion element moves an element along a path. It is defined in the SMIL 3.0 BasicAnimation module. It uses the select, from, to, by, values, calcMode, accumulate, additive, origin, begin, dur, end, fill, repeatCount, and repeatDur attributes.

The animateColor Element

This section is normative.

The animateColor element specifies an animation of a color attribute. It is defined in the SMIL 3.0 BasicAnimation module. It uses the select, from, to, by, values, calcMode, accumulate, additive, begin, dur, end, fill, repeatCount, and repeatDur attributes.

13.8 Event Model

This section is informative.

The begin, dur, and end attributes can contain references to DOM events [DOM2Events]. DOM events can be triggered by user interaction or by some other event in the document. Events are divided into two distinct groups, internal events and user events.

Internal Events

This section is informative.

Internal events are dispatched from within the timesheets. They can be used by other elements in the timesheet to create relations between different parts of the timeline. The events specified are beginEvent event, which is dispatched when an element starts and endEvent event, which is dispatched when element stops.

User Events

This section is informative.

User events are triggered by the actions that user makes. A typical example is that the user activates a link in the document, and thus a DOMActivate event is dispatched [DOM2Events].

Event Semantics

This section is informative.

A timesheet element is set to listen to a certain event by specifying the event's target and type by either begin, dur, or end attributes. When specified by the begin attribute, an inactive or active but not yet started element will be started when it receives the specified event. The parent time containers and item elements have to be active, though.

When the element is specified to stop according to an event, it doesn't cause that much processing in the timesheet. The element informs its parent that it has stopped and parent then decides what should happen next. Of course, some other element could be waiting to start according to the endEvent event from the particular element.

Index Function

This section is informative.

The index() function can be used to automatically generate index numbers for both internal and external events within begin, dur, or end attributes of item element. The following example gives an example on how index() function can be used. The example is an image show, which consist of images and corresponding thumbnail images, which can be used to select an individual image for viewing. Only one image is shown at a time.

<head>
<!DOCTYPE htmlLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:smil="http://www.w3.org/2007/07/SMIL30/Timesheets">
  <head>
    <smi:timesheet>
      <par>
        <excl>
          <item select="#Image1" begin="Thumbnail1.DOMActivate" />
          <item select="#Image2" begin="Thumbnail2.DOMActivate" />
          <item select="#Image3" begin="Thumbnail3.DOMActivate" />
          <item select="#Image4" begin="Thumbnail4.DOMActivate" />
          <item select="#Image5" begin="Thumbnail5.DOMActivate" />
        </excl>
        <par>
          <item select="#Thumbnail1" />
          <item select="#Thumbnail2" />
          <item select="#Thumbnail3" />
          <item select="#Thumbnail4" />
          <item select="#Thumbnail5" />
        </par>
      </par>
    </smil:timesheet>
  </head>
  <body>
    <img src="Image1.jpg" class="Image" id="Image1" />
    <img src="Image2.jpg" class="Image" id="Image2" />
    <img src="Image3.jpg" class="Image" id="Image3" />
    <img src="Image4.jpg" class="Image" id="Image4" />
    <img src="Image5.jpg" class="Image" id="Image5" />
    <br />
    <button class="Thumbnail" id="Thumbnail1">
      <img src="Thumbnail1.jpg" />
    </button>
    <button class="Thumbnail" id="Thumbnail2">
      <img src="Thumbnail2.jpg" />
    </button>
    <button class="Thumbnail" id="Thumbnail3">
      <img src="Thumbnail3.jpg" />
    </button>
    <button class="Thumbnail" id="Thumbnail4">
      <img src="Thumbnail4.jpg" />
    </button>
    <button class="Thumbnail" id="Thumbnail5">
      <img src="Thumbnail5.jpg" />
    </button>
  </body>
</html>

In the above example, the body of the HTML file consists of five pictures and five buttons, which contain thumbnails of the same images. The idea is to show one image at a time. The image to be shown is selected by the thumbnail buttons. Therefore, the timesheets consist of one par time container, which contains one excl and another par time container. Within the excl time container the item elements select the images, while the item elements within the second par time container select the individual thumbnail buttons. DOMActivate events cause the excl time container to change the shown image according to which button was pushed.

The problem with the above example is that each time the position of an image is changed, deleted, or added to the image show, the Timesheet has to be updated. Therefore, the Timesheet is not reusable. The main problem lies in the references to the DOMActive events, because the index numbers have to be updated. Thus, there is need to automatically generate index numbers for the DOMActivate event references in the Timesheets. The index() function can be used exactly for this purpose. In the Timesheet below, index() function is used within the begin attribute of item element, which selects the images within the excl time container.

<smil:timesheet>
  <par>
    <excl>
      <item select=".Image" begin="index(Thumbnail).DOMActivate" />
    </excl>
    <par>
      <item select=".Thumbnail" />
    </par>
  </par>
</smil:timesheet>

The index() function adds the index number to the Thumbnail parameter (e.g., Thumbnail0.DOMActivate, Thumbnail1.DOMActivate, etc.) in the begin attribute. Therefore, one ".Image" class selector can be used in the select attribute instead of severall id selectors. The main advantage of this is that changing the order of images, deleting images, or adding new images does not any longer require updating the Timesheets. Thus, the Timesheets is now much more reusable. However, there is one problem in the above example. The index numbering starts from 0. It should be corrected to start from 1 by using the indexStart attribute as shown in the example below.

<smil:timesheet>
  <par>
    <excl>
      <item select=".Image" indexStart="1" begin="index(Thumbnail).DOMActivate" />
    </excl>
    <par>
      <item select=".Thumbnail" />
    </par>
  </par>
</smil:timesheet>

Now, the index numbering starts from 1, and thus the Timesheet functions properly. However, the Timesheets can be written in even more compact format. The reason is that all the thumbnail images in buttons are allways shown, and thus the second par is actually unnecessary. When it is removed, also the first par time container becomes unnecessary. Therefore, the most simple Timesheets for this use case is as follows.

<smil:timesheet>
  <excl>
    <item select=".Image" indexStart="1" begin="index(Thumbnail).DOMActivate" />
  </excl>
</smil:timesheet>

13.9 Integration with CSS Layout

This section is informative.

Since SMIL Timesheets only describes the temporal dimension of the document, it must be integrated with a host language's layout system. It can be integrated to CSS based layout by affecting the CSS properties of media elements. For instance, the CSS display property controls whether the element is displayed or not. The SMIL Timesheets processor sets the CSS pseudo-class timed-inactive for the media element when the element should not be visible based on the timesheet. Then, with a default rule for the pseudo-class, the CSS property display is set to "none" to the non-visible media element. The pseudo-class overrides element's original display property and the element becomes invisible. When the media element should become visible, the implementation removes the pseudo-class from the element, thus restoring the original value.

The default style sheet should contain a declaration with the pseudo-class called timed-inactive that is used to control the visibility of the media elements:

:timed-inactive { display: none ! important;}

Additionally, the language is extended by defining a class attribute for the item element. It can be used to change style properties of the elements from the timesheet. For example, the author could specify the red background of an element to be changed to blue at some time. This is done by setting the value of the class attribute to reference a CSS pseudo-class that is used in the style sheet of the document. The author doesn't have to add the same document element with the same content multiple times with different style properties, but instead only define a pseudo-class for each property change and control them from the timesheet.


previous   next   contents