Movatterモバイル変換


[0]ホーム

URL:


previous  next  contents  

13. SMIL 3.0 State

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

Table of contents

13.1Overview and Summary of Changes forSMIL 3.0

This section is informative.

The modules defined in this chapter are all new modules which were notpart of the SMIL 2.1 specification.

13.2 Introduction

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.

13.3 Relation To Other Standards

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.

13.4 Module Overview

This section is normative.

This chapter defines the following modules:

13.5 The SMIL StateTest Module

13.5.1 Changes for SMIL 3.0

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.

13.5.2 Overview

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 generalizedexpr attribute that contains an expression.If the expression evaluates tofalse the elementcarrying the attribute is ignored. If the expression evaluates totrue or if there is any error (this ranges fromexpression syntax errors and type errors to unavailability of the expressionlanguage engine) the element is treated normally.

13.5.3 Elements and Attributes

This section is normative.

Theexpr Attribute

expr
This attribute contains an expression that is evaluated at runtime, i.e. each time the element becomes active. If the expression evaluates tofalse the element is ignored (including its hierarchy of descendants). If it is impossible to resolve the expression specified in the expr attribute to a boolean, user-agents must ignore the expr attribute.
Any profile using this module needs to define the language used to specify the expression.

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 usingexpr: the latter is guaranteed to bedynamically evaluated at runtime and may therefore be used for more dynamiccontrol whereas there is no such guarantee for the former.

13.5.4 Functions

This section is normative.

This module defines a set of functions for use in theexpr attribute (possibly in addition tofunctions already defined in the expression language). The naming conventionused for the functions is compatible with XPath 1.0 expressions, a profileusing this module with another expression language must specify atransformation that needs to be applied to these function names to make themcompatible with the expression language specified.

booleansmil-audioDesc()
Corresponds tosystemAudioDesc.
numbersmil-bitrate()
Corresponds tosystemBitrate.
booleansmil-captions()
Corresponds tosystemCaptions.
booleansmil-component(string uri)
Corresponds tosystemComponent, checks for availability of a single playback component.
booleansmil-customTest(string name)
Corresponds tocustomTest, checks the current state of the given custom test.
stringsmil-CPU()
Related tosystemCPU. This function returns the CPU on which the user agent runs.
numbersmil-language(string lang)
Related tosystemLanguage. The string argument should be a BCP47[BCP47] language tag. If the language does not match any language range in the users' preferences the function returns0. If the tag does match the function returns a positive number, such that languages that match higher in the language priority list return a higher number.
stringsmil-operatingSystem()
Related tosystemOperatingSystem. This function returns the operating system on which the user agent runs.
stringsmil-overdubOrSubtitle()
Values:overdub orsubtitle
Corresponds tosystemOverdubOrSubtitle.
booleansmil-required(string uri)
Corresponds tosystemRequired.
numbersmil-screenDepth()
Corresponds tosystemScreenDepth.
numbersmil-screenHeight()
Related tosystemScreenSize, returns the height of the screen in pixels.
numbersmil-screenWidth()
Related tosystemScreenSize, returns the width of the screen in pixels.

13.5.5 Examples

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() &gt; 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') &gt;= smil-systemLanguage('en')" />      <img src="colour.jpg" expr="smil-systemLanguage('en')" />      <img src="couleur.jpg" />    </switch>

13.6 The SMIL UserState Module

13.6.1 Changes for SMIL 3.0

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.

13.6.2 Overview

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).

13.6.3 Elements and Attributes

This section is normative.

The UserState module defines the elementsstate,setvalue,newvalue anddelvalue and the attributeslanguage,ref,where,name andvalue.

Thestate Element

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 thesrc attribute is not specified or if thedocument it refers to cannot be found.

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 asrc attribute allows the former to be used asa fallback mechanism.

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.

Element Attributes

Thestate element accepts thelanguage andsrc attributes.

ThesetvalueElement

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 SMILref element.

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.

Element Attributes

Thesetvalue element accepts theref andvalue attributes. Both of these are requiredattributes.

ThenewvalueElement

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 thenewvalue element more than once. In caseof such an error SMIL Timing semantics of the element are not affected.

Theref andwhere determine where in the data model thenew item is introduced. If the expression language does not support ahierarchical namespace these attributes are ignored. Thename attribute determines the name for thenew item.

Element Attributes

Thenewvalue element accepts theref,where,name andvalue attributes. Which of these arerequired depends on the expression language.

ThedelvalueElement

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.

Element Attributes

Thedelvalue element accepts theref attribute.

ThelanguageAttribute

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 thesystemComponent attribute.

Theref Attribute

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 aname attribute is that some languages,notably XPath 1.0, do not supportrefreferring to a non-existing named item in the data model. Therefore,name is used to give the name for the newitem andref andwhere specify where it is inserted. For expressionlanguages without a hierarchical namespaceref andwhere should be omitted and onlyname is needed.

This section is informative.

For the SMIL 3.0 Language Profile the value of theref attribute is an XPath expression thatevaluates to anode-set. It is an error if thenode-set does not refer to exactly one node.

ThewhereAttribute

Thewhere attribute indicates wherein the data model the new item will be inserted, if the expression languagesupports a hierarchical data model. The allowed values arebefore,after andchild, the default.

ThenameAttribute

Thename attribute specifiesthe name for the new data model item. This name must adhere to constraintsset by the expression language used.

ThevalueAttribute

Thevalue attribute specifies the newvalue of the data model item referred to by theref element. How the new value is specified inthevalue attribute is defined in theprofile that includes this module. This specification also states whetheronly simple values are allowed or also expressions, and when thoseexpressions are evaluated.

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 theref.

13.6.4 Examples

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 &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>

13.6.5 Data Model

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 formcount has the same meaning as one of the form/data/count. Moreover, the XPath type conversion rulesresult incount + 1 in meaning the exact samethings asnumber(/data/count) + 1.

Data Model Examples

Here is the minimalstate sectionthat corresponds to theaudio clipexample above:

    <smil>     <head>      <state>         <data xmlns="">          <lastPlayed>0</lastPlayed>         </data>      </state>      ...

Expression Constraints

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.

13.6.6 Data Model Events

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.

stateChange(ref)
Raised by thestate element. The parameter is a reference to an item (or multiple items) in the data model. Whenever any of the data model items referenced by the parameter is changed this event is raised. The event does not bubble.
contentControlChange(attrname)
Raised by the root of the SMIL document when the named Content Control test values has changed. The list of allowed values forattrname is taken from the Content Control Module attribute names. The event does not bubble.
contentControlChange
Raised by the root of the SMIL document when any Content Control test value has changed. The event does not bubble.

Raising thestateChange event on thestate element instead of on the data modelelement itself allows for external data models (which have a distinctxmlid-space) and on non-XML data models (depending on the expressionlanguage).

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.

13.7 The SMIL StateSubmission Module

13.7.1 Changes for SMIL 3.0

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.

13.7.2 Overview

This section is informative.

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

13.7.3 Elements andAttributes

This section is normative.

The StateSubmission module defines two elements,submission andsend, and the attributessubmission,action,method,replace andtarget.

ThesubmissionElement

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:"/"). The other attributes are explained below.

Element Attributes

Thesubmission element acceptstheref,action,method,replace andtarget attributes. Theaction andmethod attributes are required.

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

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.

Element Attributes

Thesend element accepts thesubmission attribute.

ThesubmissionAttribute

Thesubmission attribute is anIDREF that should refer to asubmission element.

TheactionAttribute

A URL specifying where to transmit or save the nodeset. Which URLs areallowable must take security and privacy considerations into account.

ThemethodAttribute

How to serialize and transmit the data. Allowed values are at leastput andget but may beextended by the profile.

put andget mustbe symmetrical, and if there is a canonical external representation for thedata model languageput must create thatrepresentation.

ThereplaceAttribute

What to replace with the reply. Allowed values areall for the whole SMIL presentation,instance for the instance data,none for nothing.

ThetargetAttribute

If the value ofreplace isinstance, the optionaltarget attribute specifies which partof the data model to replace. The default is to replace the whole instance.

This section is informative.

The SMIL 3.0 Language Profile includes the StateSubmission module, and itdefines that thesubmissionelement must occur in thehead section.

13.7.4 Examples

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 &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>        </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 &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>      </par>

That last example is actually a procedural roundabout way to get the sameeffect as using<statesrc="http://www.example.com/loadxmldoc" /> without submissions.

13.8 The SMIL StateInterpolation Module

13.8.1 Changes for SMIL 3.0

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.

13.8.2 Overview

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{expression} anywhere inside an attribute value. Theexpression is evaluated, converted to a string value and substituted into theattribute value.

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.

13.8.3 Elements andAttributes

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,href,clipBegin andclipEnd attributes. It disallows its useon the Timing and Synchronization attributes. Its use on other attributes isimplementation-dependent.

13.8.4 Examples

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>

13.8.5 StateInterpolation, Animationand DOM access

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.


previous  next  contents  

[8]ページ先頭

©2009-2025 Movatter.jp