This section is informative.
The modules defined in this chapter are all new modules which were notpart of the SMIL 2.1 specification.
This section is informative.
A SMIL 2.1 presentation has a lot of state that influences how thepresentation runs. Or, to rephrase that in a procedural way, state thatinfluences decisions that the SMIL scheduler makes. All this state is eitherimplicit in the presentation (what nodes are active and how long into theirduration they are, how many iterations of a repeat we have done, which nodesin anexcl are paused because a higherpriority node has preempted them, etc.), or completely external to thepresentation (system tests and custom tests).
This has the effect that the only control flow that the SMIL author has athis/her disposal is that which is built in to the language, unless the SMILengine includes some scripting language component and a DOM interface to thedocument that the author may use to create more complex logic.
The modules in this section provide a mechanism whereby the documentauthor may create more complex control flow than what SMIL provides throughthe timing and content control modules, without having to go all the way ofusing a scripting language. One way to provide this is to allow a document tohave some explicit state (think: variables) along with ways to modify, useand save this state.
In addition, the mechanisms that the SMIL BasicContentControl andCustomTestAttributes modules provide for testing values are limited:basically one can only test for predefined conditions being true (not forthem being false) and there is a limited form of testing for multipleconditions with "and" being the only boolean operator.
Application areas include things like quizzes, interactive adaptation ofpresentations to user preferences, computer-aided instruction and distantlearning.
This section is informative.
The design of these modules was done after meeting with the W3C BackplaneGroup (part of the Hypertext Coordination Group) and various choices wereinfluenced by the direction that group is taking.
These modules therefore borrow heavily from work done by other W3C workinggroups:
The intention of these modules it to provide authors with the minimumfunctionality required to create compelling presentations, not to import allfunctionality from the standards they were lifted from, and concentrate onthe timing integration issues. Applications requiring a richer set ofprimitives should import, for example, the XForms data model through the XMLnamespace mechanism.
This section is normative.
This chapter defines the following modules:
This section is informative.
The SMIL 3.0 StateTest Module defined in this document is a new modulewhich was not part of the SMIL 2.1 specification.
This section is informative.
The mechanisms that the BasicContentControl and CustomTestAttributesmodules provide for testing values are limited: basically one can only testfor predefined conditions being true (not for them being false) and byspecifying multiple system test attributes an author has a way to simulate anand operator but that is all.
This module introduces a generalized
This section is normative.
This section is informative.
The SMIL 3.0 Language Profile specifies that XPath 1.0 is used as thedefault expression language, and the context in which the expressions areevaluated is as follows:
Alternative expression languages that could be used are a scaled down formof XPath as used by DI, or EcmaScript, Python, Lua or any other languagesuitable for the application domain of the profile.
Note that there is a slight but important semantic difference betweenusing content control attributes and using
This section is normative.
This module defines a set of functions for use in the
This section is informative.
Here is a SMIL 3.0 Language Profile example of an audio element that isonly played if audio descriptions are off and the internet connection isfaster than 1Mbps. Think of using it for playing background music only whenthis will not interfere too much with the real presentation:
<audio src="background.mp3" expr="not(smil-audioDesc()) and smil-bitrate() > 1000000" />
Here is an example that will show the image colour.jpg to mostenglish-speaking people. However, people preferring American English overother variants of english will see color.jpg. Non-english speaking peoplewill see couleur.jpg.
<switch> <img src="color.jpg" expr="smil-systemLanguage('en-us') >= smil-systemLanguage('en')" /> <img src="colour.jpg" expr="smil-systemLanguage('en')" /> <img src="couleur.jpg" /> </switch>
This section is informative.
The SMIL 3.0 UserState Module defined in this document is a new modulewhich was not part of the SMIL 2.1 specification.
This section is informative.
This section introduces a data model that document authors may refer to inthe context of theexpr attribute,allowing elements to be rendered depending on author-defined values. Amechanism to change values in the data model is also included.
The actual choice of the expression language is made in the languageprofile. The SMIL 3.0 Language Profile requires support for the XPath 1.0expression language (but allows use of other languages as well).
This section is normative.
The UserState module defines the elements
Thestate element sets global,document-wide, information for the other elements and attributes in thismodule. It selects the expression language to use and it may also be used toinitialize the data model.
Initialization of the data model may be done in-line, through the contentsof thestate element, or from anexternal source through thesrcattribute (defined in the Media Object Modules section).
Thesrc takes precedence over theinline content, which is only used if the
Initialization of the data model (including retrieval of the data) happensat the beginning of document playback. This may include modifications to thedata model to make it play well with SMIL State use. Such modifications mustbe defined in the profile including this module.
This section is informative.
Allowing both inline content and a
Note that beginning of document playback may be different than documentparse time: depending on the user interface of the user agent a document maybe played multiple times after being parsed once.
The SMIL language profile specifies that, in the case of using the XPathdata model, an empty data model will be modified so that it consists of asingle empty<data/> root element.
Thestate element accepts the
Thesetvalue element modifiesthe value of an item in the data model, similar to the corresponding elementfrom XForms, but it takes its time behaviour from the SMIL
Note thatsetvalue only modifiesexisting items, it is therefore an error to specify a non-existing item,depending on the expression language semantics. In case of such an error SMILTiming semantics of the element are not affected.
Thesetvalue supports all timingattributes, and participates normally in timing computations. The effect ofsetvalue happens at the beginningof its simple duration.
Thesetvalue element accepts theref and
Thenewvalue element introducesa new, named, item into the data model.
Thenewvalue supports all timingattributes, and participates normally in timing computations. The effect ofnewvalue happens at the beginningof its simple duration. Depending on the semantics of the expression languageit may be an error to execute the
Theref and
Thenewvalue element accepts theref,
Thedelvalue element deletes anamed item from the data model.
Thedelvalue supports all timingattributes, and participates normally in timing computations. The effect ofdelvalue happens at the beginningof its simple duration. Depending on the semantics of the expression languagedeletion of variables may not be supported, or it may be an error to executethedelvalue element on anon-existing item. In case of such errors SMIL Timing semantics of theelement are not affected.
Thedelvalue element accepts theref attribute.
Thelanguage attribute selectsthe expression language to use. Its value should be a URI defining thatlanguage. The default value for this attribute is defined in the profile.
SMIL implementations should allow expression language availability to betested through the
Theref attribute indicates whichitem in the data model will be changed. The language used to specify this,plus any additional constraints on the attribute value, depend on theexpression language used.
This section is informative.
The reason thatnewvalue hasboth aref and a
This section is informative.
For the SMIL 3.0 Language Profile the value of the
Thewhere attribute indicates wherein the data model the new item will be inserted, if the expression languagesupports a hierarchical data model. The allowed values are
Thename attribute specifiesthe name for the new data model item. This name must adhere to constraintsset by the expression language used.
Thevalue attribute specifies the newvalue of the data model item referred to by the
If a statically-typed language is used as the data model language it is anerror if the type of thevalue expressioncannot be coerced to the type of the item referred to by the
This section is informative.
Here is a SMIL 3.0 Language Profile example of a sequence of audio clipsthat remembers the last audio clip played, omitting the state declaration inthe head for brevity:
<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 clipremembered but if this sequence is played again, later during thepresentation, any audio clips played previously are skipped:
<seq> <seq expr="lastPlayed < 1"> <audio src="chapter1.mp3" /> <setvalue ref="lastPlayed" value="1" /> </seq> <seq expr="lastPlayed < 2"> <audio src="chapter2.mp3" /> <setvalue ref="lastPlayed" value="2" /> </seq> <seq expr="lastPlayed < 3"> <audio src="chapter3.mp3" /> <setvalue ref="lastPlayed" value="3" /> </seq> </seq>
This section is informative.
As stated before, the normative choice of an expression language and datamodel is made in the profile that includes this module, but for ease ofreading this section informatively describes the choices in the SMIL 3.0Language Profile: XPath 1.0 operating on a simple XML document contained inthestate element.
It is important to note that the data model is an XML document. This isnot to be confused with the variable bindings in the expression context,another namespace that XPath has. These variable bindings are not supportedthrough SMIL State. Therefore references to state elements are node-setexpressions, not$name-style variable references. This usage allowsfor nested variables and more complex data structures than the flat namespaceof the variable bindings provides. SMIL follows the lead of XForms here.
Thestate element, of which at mostone may occur, in thehead section,should either be empty or contain a well-formed XML document.
The XPath context in which the expressions are evaluated is as follows:
This context means that an expression of the form
Here is the minimalstate sectionthat corresponds to theaudio clipexample above:
<smil> <head> <state> <data xmlns=""> <lastPlayed>0</lastPlayed> </data> </state> ...
The UserState module does not constrain the data model and expressions ofthe underlying language, unless specifically done so in a profile. For easeof reading most examples in this document use simple variable-style names,but richer constructs, such as setting attribute values with XPath or usingcompound values in Python, are allowed.
This section is informative.
Supported events for event-based timing are normatively specified in theprofile. For ease of reading we include the relevant event defined in theSMIL 3.0 Language Profile here as well. The purpose of these events is toallow document authors to create documents (or sections of documents) thatrestart and re-evaluate conditional expressions whenever the valuesunderlying the expressions have changed.
Raising thestateChange event on the
If any of the Content Control test values changes both the specific eventand the general event are raised. This is because for some documents theauthor will want to react to a change in a specific parameter (bandwidth,screensize) only, whereas for other use cases the author may want toreconfigure the whole presentation on any change.
This section is informative.
The SMIL 3.0 StateSubmission Module defined in this document is a newmodule which was not part of the SMIL 2.1 specification.
This section is informative.
This section introduces a method to save author defined state or totransmit it to an external server.
This section is normative.
The StateSubmission module defines two elements,
Thesubmission element carriesthe information needed to determine which parts of the data model should besent, where it should be sent and what to do with any data returned. Theref attribute selects the portion of thedata model to transmit and in case of XPath should be a node-set expression.The default is to transmit the whole data model (in case of xpath:
Thesubmission element acceptstheref,
Depending on themethod thiselement describes either transmission of data, reception of data or both. Theref element is ignored if notransmission happens. Thereplaceandtarget attributes areignored if no reception happens.
This section is informative
This element was lifted straight from XForms, with the accompanyingattributes. Support for asynchronous submission and the corresponding eventsare not needed because of SMIL's inherent parallelism.
Thesend element causes the datamodel, or some part of the data model, to be submitted to server, saved todisk or transmitted externally through some other method. It does not specifyany of this directly but contains only a reference to such submissioninstructions.
Thesend supports all timingattributes, and participates normally in timing computations. The effect ofsend happens at the beginning of itssimple duration.
Thesend element accepts the
Thesubmission attribute is anIDREF that should refer to a
A URL specifying where to transmit or save the nodeset. Which URLs areallowable must take security and privacy considerations into account.
How to serialize and transmit the data. Allowed values are at least
put andget mustbe symmetrical, and if there is a canonical external representation for thedata model languageput must create thatrepresentation.
What to replace with the reply. Allowed values are
If the value ofreplace is
This section is informative.
The SMIL 3.0 Language Profile includes the StateSubmission module, and itdefines that thesubmissionelement must occur in thehead section.
This section is informative.
Here is an example of asynchronous submission: whenever the lastPlayeditem changes because another clip has been played this fact is communicatedto some server.
<smil> <head> <state xml:id="stateid"> <data xmlns=""> <lastPlayed>0</lastPlayed> </data> </state> <submission xml:id="subid" action="http://www.example.com/savexmldoc" method="put" /> </head> <body> <par> <send submission="subid" begin="stateid.stateChange(lastPlayed)" restart="always" /> ... <seq end="... some interactive end condition ..." > <seq expr="lastPlayed < 1"> <audio src="chapter1.mp3" /> <setvalue ref="lastPlayed" value="1" /> </seq> <seq expr="lastPlayed < 2"> <audio src="chapter2.mp3" /> <setvalue ref="lastPlayed" value="2" /> </seq> <seq expr="lastPlayed < 3"> <audio src="chapter3.mp3" /> <setvalue ref="lastPlayed" value="3" /> </seq> </seq> </par>
In another presentation we could pick this value up again synchronouslyand use it.
<smil> <head> <state> </state> <submission xml:id="subid" action="http://www.example.com/loadxmldoc" replace="instance" method="get" /> </head> <body> <par> ... <seq > <send submission="subid" /> <seq expr="lastPlayed < 1"> <audio src="chapter1.mp3" /> <setvalue ref="lastPlayed" value="1" /> </seq> <seq expr="lastPlayed < 2"> <audio src="chapter2.mp3" /> <setvalue ref="lastPlayed" value="2" /> </seq> <seq expr="lastPlayed < 3"> <audio src="chapter3.mp3" /> <setvalue ref="lastPlayed" value="3" /> </seq> </seq> </par>
That last example is actually a procedural roundabout way to get the sameeffect as using<statesrc="http://www.example.com/loadxmldoc" /> without submissions.
This section is informative.
The SMIL 3.0 StateInterpolation Module defined in this document is a newmodule which was not part of the SMIL 2.1 specification.
This section is normative.
This section introduces a mechanism whereby document authors may usevalues from the data model to construct attribute values at runtime. Themechanism has been borrowed fromXSLT attributevalue templates.
Substitution is triggered by using the construct
This substitution happens when the element containing the attribute withthe{expression} attribute becomes active.
If any error occurs during the evaluation of the expression nosubstitution takes place, and the{expression}construct appears verbatim in the attribute value.
If a profile includes this module it must list all attributes for whichthis substitution is allowed. It must use the same expression language forinterpolation as the one used for StateTest expressions.
This section is normative.
This module does not define any new elements or attributes.
This section is informative
The SMIL 3.0 Language Profile includes the StateInterpolation module. Itallows its use in the same set of attributes for which SMIL animation isallowed plus thesrc,
This section is informative.
This SMIL 3.0 Language Profile example shows an icon corresponding to thecurrent CPU on which the user views the presentation, or a default icon foran unknown CPU:
<switch> <img src="cpu-icons/{smil-CPU()}.png" /> <img src="cpu-icons/unknown.png" /> </switch>
This section is normative.
Because StateInterpolation may also change attribute values itsinteraction with animation and DOM access needs to be defined, the so-called"sandwich model". StateInterpolation sits between DOM access and animation,i.e. DOM access will see the{expression} stringsverbatim and it may set these values too. SMIL animation will operate on thevalue of the expression.