previous   next   contents  

15. The SMIL 3.0 State Modules

Editors for SMIL 3.0
Jack Jansen, CWI
Julien Quint, DAISY Consortium

Table of contents

15.1 Overview and Summary of Changes for SMIL 3.0

This section is informative.

The modules defined in this Chapter are all new modules which were not part of the SMIL 2.1.

15.2 Open Issues In This Version

The open issues at the time of writing this version of the SMIL State modules are:

15.3 Introduction

This section is informative.

A SMIL 2.1 presentation has a lot of state that influences how the presentation runs. Or, to rephrase that in a procedural way, state that influences decisions that the SMIL scheduler makes. All this state is either implicit in the presentation (what nodes are active and how long into their duration they are, how many iterations of a repeat we have done, which nodes in an excl are paused because a higher priority node has preempted them, etc), or completely external to the presentation (system tests and custom tests).

This has the effect that the only control flow that the SMIL author has at his/her disposal is that which is built in to the language, unless the SMIL engine includes some scripting language component and a DOM interface to the document that the author can use to create more complex logic.

In addition, the mechanisms that the BasicContentControl and CustomTestAttributes modules provide for testing values are limited: basically one can only test for predefined conditions being true (not for them being false) and there is a limited form of testing for multiple conditions with "and" being the only boolean operator.

The modules in this section provide a mechanism whereby the document author can create more complex controlflow than what SMIL provides through the timing and content control modules, without having to go all the way of using a scripting language. One way to provide this is to allow a document to have some explicit state (think: variables) along with ways to modify, use and save this state.

Application areas include things like quizzes, interactive adaptation of presentations to user preferences, computer-aided instruction and distant learning.

This section is informative.

The design of these modules was done after meeting with the W3C Backplane Group (part of the Hypertext Coordination Group) and various choices were influenced by the direction that group is taking.

These modules therefore borrow heavily from work done by other W3C working groups:

15.5 Module Overview

This section is normative.

This chapter defines the following modules:

15.6 The SMIL StateTest Module

15.6.1 Changes for SMIL 3.0

This section is informative.

The SMIL 3.0 StateTest Module defined in this document is a new module which was not part of the SMIL 2.1.

15.6.2 Overview

This section is informative.

The mechanisms that the BasicContentControl and CustomTestAttributes modules provide for testing values are limited: basically one can only test for predefined conditions being true (not for them being false) and by specifying multiple system test attributes an author has a way to simulate an and operator but that is all.

This module introduces a generalized expr attribute that contains an expression. If the expression evaluates to false the element carrying the attribute is ignored.

15.6.3 Elements and Attributes

This section is normative.

The expr Attribute

expr
This attribute contains an expression that is evaluated at runtime. (1) Need to define runtime. Load time, when the whole timing tree is built and the presentation is ready to run and activation time, when the element on which the attribute is is activated, are the candidates. We may want to specify this or we may leave this specification to the profiles. (2) The name "expr" is rather general. Something like "pred" may be better, but deviates from what DI uses. If the expression evaluates to false the element carrying the attribute is ignored (and so are its children).
Any profile using this module needs to define the language used to specify the expression. The SMIL 3.0 Language Profile specifies that XPath 1.0 is used. Alternatives that could be used by other languages are a scaled down form of XPath as used by DI, EcmaScript or any other language suitable for the application domain of the profile. Need to add references.

15.6.4 Functions

This section is normative.

This module defines a number of functions for use in the expr attribute. The naming convention used for the functions is compatible with XPath 1.0 expressions, a profile using this module with another expression language must specify a transformation that needs to be applied to these function names to make them compatible with the expression language specified.

boolean smil-audioDesc()
Corresponds to systemAudioDesc.
number smil-bitrate()
Corresponds to systemBitrate.
boolean smil-captions()
Corresponds to systemCaptions.
boolean smil-component(string uri)
Corresponds to systemComponent, checks for availability of a single playback component.
boolean smil-customTest(string name)
Corresponds to customTest, checks the current state of the given custom test.
string smil-CPU()
Related to systemCPU. This function returns the CPU on which the user agent runs.
boolean smil-language(string lang)
Corresponds to systemLanguage. May want to rethink this one. On the one hand we want easy boolean tests, on the other hand we could provide more information. We may want to add another function that returns the users' preferred language/region as a string.
string smil-operatingSystem()
Related to systemOperatingSystem. This function returns the operating system on which the user agent runs.
string smil-overdubOrSubtitle()
Values: overdub or subtitle
Corresponds to systemOverdubOrSubtitle.
boolean smil-required(string uri)
Corresponds to systemRequired.
number smil-screenDepth()
Corresponds to systemScreenDepth.
number smil-screenHeight()
Related to systemScreenSize, returns the height of the screen in pixels.
number smil-screenWidth()
Related to systemScreenSize, returns the width of the screen in pixels.

15.6.5 Examples

This section is informative.

Here is a SMIL 3.0 Language Profile example of an audio element that is only played if audio descriptions are off and the internet connection is faster than 1Mbps. Think of using it for playing background music only when this will not interfere too much with the real presentation:

   <audio src="background.mp3" expr="not(smil-audioDesc()) and smil-bitrate() &gt; 1000000" />
   

15.7 The SMIL UserState Module

15.7.1 Changes for SMIL 3.0

This section is informative.

The SMIL 3.0 UserState Module defined in this document is a new module which was not part of the SMIL 2.1.

15.7.2 Overview

This section is informative.

This section introduces a data model that document authors can refer to in the context of the expr attribute, allowing elements to be rendered depending on author-defined values. Elements to change values in the data model are also included.

The actual choice of the data model is made in the language profile. The SMIL 3.0 Language Profile uses the XForms 1.0 data model.

15.7.3 Elements and Attributes

This section is normative.

The UserState module defines one element, setvalue, and two attributes, ref and value. We may also want to define a newvalue element that inserts a new element into the data model.

The setvalue Element

The setvalue element modifies the value of an item in the data model, similar to the corresponding element from XForms, but it takes its time behaviour from the SMIL BasicAnimation set element.

Note that setvalue only modifies existing items, it is therefore an error to specify a non-existing item.

The setvalue supports all timing attributes, but practically speaking only begin time is important and repeat and duration are ignored.

Element Attributes

The setvalue element accepts the ref and value attributes. Both of these are required attributes.

The ref Attribute

The ref attribute indicates which item in the data model will be changed. The language used to specify this, plus any additional constraints on the attribute value, are defined in the profile that includes this module.

For the SMIL 3.0 Language Profile the value of the ref attribute is an XPath expression that must evaluate to a nodeset.

The value Attribute

The value attribute specifies the new value of the data model item referred to by the ref element. How the new value is specified in the value attribute is defined in the profile that includes this module. This specification also states whether only simple values are allowed or expressions are too, and when those expressions are evaluated.

For the SMIL 3.0 Language Profile the value attribute value is an XPath expression. If the item begin changed is typed with XML Schema then the value is coerced to that type. If this coercion is not possible this is an error.

15.7.4 Examples

This section is informative.

Here is a SMIL 3.0 Language Profile example of a sequence of audio clips that remembers the last audio clip played.

   <seq>
       <audio src="chapter1.mp3" />
       <setvalue ref="lastPlayed" value="1" />
       <audio src="chapter2.mp3" />
       <setvalue ref="lastPlayed" value="2" />
       <audio src="chapter3.mp3" />
       <setvalue ref="lastPlayed" value="3" />
   </seq>
   

Here is an extension of the previous example: not only is the last clip remembered but if this sequence is played again, later during the presentation, any audio clips played previously are skipped:

   <seq>
       <seq expr="lastPlayed &lt; 1">
           <audio src="chapter1.mp3" />
           <setvalue ref="lastPlayed" value="1" />
       </seq>
       <seq expr="lastPlayed &lt; 2">
           <audio src="chapter2.mp3" />
           <setvalue ref="lastPlayed" value="2" />
       </seq>
       <seq expr="lastPlayed &lt; 3">
           <audio src="chapter3.mp3" />
           <setvalue ref="lastPlayed" value="3" />
       </seq>
   </seq>
   

15.7.5 Data Model

This section is informative.

As stated before, the actual choice of a data model is made in the profile that includes this module, but for ease of reading this section describes the data model used in the SMIL 3.0 Language Profile.

SMIL 3.0 uses the data model defined by XForms 1.0, see Introduction to XForms. This is a hierarchical data model with optional typing (through XML Schema) and spreadsheet-like dependencies between data items. There is a separation between the model, which contains the typing information and dependencies, and the instances, which contain the actual data. Instances are stored as XML trees, and can be contained in-line in the document or loaded from an external source. Instance data can also come from multiple places.

We are not sure the full XForms model is needed. We may want to cut down to the basic types, and we may introduce another, more minimal, data model. If we also have a newvalue element this would allow for basic state manipulation without exposing the SMIL author to all the details of data model, instance, etc.

The model is declared in the head, inside a state element. The XForms tags are not imported into the SMIL namespace, hence they need to use a namespace prefix.

Here is a quick breakdown of the most important tags:

model
Outer element for the data model. Contains all the other elements. An optional schema can be specified with the schema attribute.
instance
Defines some instance data for the model. Instance data can be contained as in-line XML or referenced through a src attribute.
bind
Defines constraints on data model elements. The elements to which the constraints apply are given with a nodeset attribute which takes an XPath expression. The expression can evaluate to multiple items. Type information for the nodeset can be given with the type attribute, pass an XML Schema type as parameter. Automatic value calculation can be specified through the calculate attribute, which expects an XPath expression.
submission
This element, which is only used if the StateSubmission module is included, determines how and where the instance data can be saved or transmitted. The most important attributes are:
ref
An XPath expression specifying the nodeset that is to be transmitted (default: / meaning everything).
action
A URL specifying where to transmit or save the nodeset.
method
How to serialize and transmit the data (such as post).
replace
What to replace with the reply: all for the whole SMIL presentation, instance for the instance data, none for nothing.

Data Model Examples

Here is the minimal state section that corresponds to the audio clip example above:

    <smil>
     <head>
      <state xmlns:f="http://www.w3.org/2002/xforms">
       <f:model>
        <f:instance>
         <data xmlns="">
          <lastPlayed>0</lastPlayed>
         </data>
        </f:instance>
       </f:model>
      </state>
      ...
  

Here is a more elaborate version of the previous example, which contains type checking, an automatic calculation and a submission tag that would save everything to a local file:

    <smil>
     <head>
      <state xmlns:f="http://www.w3.org/2002/xforms">
       <f:model>
        <f:instance>
         <data xmlns="">
          <lastPlayed>0</lastPlayed>
          <allPlayed/>
         </data>
        </f:instance>
        <f:bind nodeset="lastPlayed" type="xsd:integer"/>
        <f:bind nodeset="allPlayed" calculate="../lastPlayed &gt;= 3"/>
        <f:submission id="save" action="file:playstate.xml" method="post" replace="none"/>
       </f:model>
      </state>
      ...
  

15.8 The SMIL StateSubmission Module

15.8.1 Changes for SMIL 3.0

This section is informative.

The SMIL 3.0 UserState Module defined in this document is a new module which was not part of the SMIL 2.1.

15.8.2 Overview

This section is informative.

This section introduces a method to save author defined state or to transmit it to an external server.

15.8.3 Elements and Attributes

This section is normative.

The StateSubmission module defines one element, send, and one attribute, submission.

The send Element

The send element causes the data model, or some part of the data model, to be submitted to server, saved to disk or transmitted externally through some other method. It does not specify any of this directly but contains only a reference to such submission instructions.

The setvalue supports all timing attributes, but practically speaking only begin time is important and repeat and duration are ignored.

Element Attributes

The send element accepts the submission attribute.

The submission Attribute

The submission attribute references a set of submission parameters by name. Where and how such submission parameters are declared is specified in the profile that includes the StateSubmission module.

For the SMIL 3.0 Language Profile the value of the submission attribute is an IDREF that points to an XForms submission element within the data model.

15.8.4 Examples

This section is informative.

To be provided.

15.9 The SMIL StateInterpolation Module

15.9.1 Changes for SMIL 3.0

This section is informative.

The SMIL 3.0 StateInterpolation Module defined in this document is a new module which was not part of the SMIL 2.1.

15.9.2 Overview

This section is normative.

This section introduces a mechanism whereby document authors can use values from the data model to construct attribute values at runtime. The mechanism has been borrowed from XSLT attribute value templates.

Substitution is triggered by using the construct {expression} anywhere inside an attribute value. The expression is evaluated, converted to a string value and substituted into the attribute value.

If a profile includes this module it must list all attributes for which this substitution is allowed. It must use the same expression language for interpolation as the one used for StateTest expressions.

This section is informative

The SMIL 3.0 Language Profile includes the StateInterpolation module, and allows its use in the src and href attributes. The exact list of attributes remains to be decided. The intention is to include only attributes that will not influence the time graph if their value is changed during the presentation. SMIL Animation probably provides a good starting point for such a list.

15.9.3 Elements and Attributes

This section is normative.

This module does not define any new elements or attributes.

15.9.4 Examples

This section is informative.

This SMIL 3.0 Language Profile example shows an icon corresponding to the current CPU on which the user views the presentation, or a default icon for an unknown CPU:

   <switch>
    <img src="cpu-icons/{smil-CPU()}.png" />
    <img src="cpu-icons/unknown.png" />
   </switch>
  

previous   next   contents