The <switch> Element

Definition and Usage

The <switch> element allows for defining alternative objects (represented by <media>, <context> or other <switch> elements) to be presented. The choice is madeduring presentation time.

Test rules used to choose the switch’schild component to be presented are defined by <rule> and <compositeRule> elements; <bindRule> child elements associate these rules to child component objectsof the <switch> element.

A <switchPort> child element may define a mapping to a subset of the switch’s child components. When a link is bound to a <switchPort> element,the rules bound to mapped components are evaluated in the order they are defined. The first rule evaluated as true determines the chosen object. Ifall rules bound to mapped components are evaluated as false, a default component, defined by the <defaultComponent>child element,is chosen; if the <defaultComponent> element is not defined, no component is selected for presentation and the NCL player behaves as if the selected component does not exist.

All references to a switch’s child component are made through <switchPort> elements or, by default, to the <switch> element without specifying any <switchPort>. In this case, it is considered as if the reference is made to a default <switchPort> that contains mapping elements to each child object of the switch and referring to its whole content anchor.

From the moment a <switch> is evaluated, it is considered resolved until the end of the current switch presentation.

The <switch> element may refer to another <switch> element. In this case, it has the same specification of the referred element.


Element Attributes Content Parent
<switch> id, refer (<defaultComponent>?, (<switchPort> | <bindRule> | <media> | <context> | <switch>)*) <body> or <context> or <switch>


Name Value Description
id It may receive any string value that begins with a letter or an underscore and that only contains letters, digits, “.”, and “_”. The id attribute uniquely identifies the element within a document.
refer IDREF or the string “alias#id” where “id” is an IDREF value.

The refer attribute refers to an element id that will be reused. An element that refers to another element cannot be reused; that is, its id cannot be reused; that is, its id cannot be the value of any refer attribute. The referred element shall be a <switch> element.

The referred element and the element that refers to it shall be considered the same only regarding their data specification.

If the referred node is defined within an imported document D, the refer attribute value shall have the format “alias#id”, where “alias” is the value of the alias attribute associated with the imported component D.

Back to top