Channel Script Selection

In addition to rendering data from data files, it is usually necessary to render the current location within the CDF so that the user can navigate to the desired data. When it is necessary to render a CDF navigation page in the browser, the appropriate script must be selected. Channel scripts are responsible for rendering the CDF navigation pages supplied by a content provider. As with an item script, referencing the URL of the subchannel results in the invocation of a channel script. The appropriate script is selected based upon the proximity of a CHANSCRIPT tag to the particular CHANNEL element in the URL.

A channel URL in a script is of the following form.

mctp://CDFid/ChanId

Here, “mctp://” specifies the use of the Mobile Channels Transport Protocol to resolve the URL and to invoke the scripting engine. CDFid is the ID tag of the top-level CHANNEL element. It is used to scope ChanId to the correct CDF file. ChanId is the ID tag of the CHANNEL element for the subchannel within the CDF to be rendered. The user navigates through the CDF channel hierarchy, accessing data files throughout the process. At each level in the channel hierarchy, it is possible to associate a script to display the channel content; this content is usually a list of subchannels or available items

The manner in which the CHANSCRIPT element identifies the script to be used to display the current channel location is similar to how the ITEMSCRIPT element identifies the script to display data. The location of a CHANNEL element relative to a CHANSCRIPT element determines which script is used to render the subchannel. The script file is identified by matching the ID value in the CHANSCRIPT element with the ID value of an ITEM element  — that is, the ITEM for the script file — within the CDF.

CHANSCRIPT elements are children of CHANNEL elements. A CHANSCRIPT element determines the script to be used for the current channel and its subchannels. A CHANSCRIPT tag specified for a CHANNEL element supercedes any CHANSCRIPT value previously defined in the CDF file.

Thus, an inheritance model is used. When it is necessary to render a particular subchannel, the nearest CHANSCRIPT parent element in the hierarchy is used to determine which script should render the data. In the event that the appropriate script is not available on the device, a built-in script is used to render the channel.

In the previous CDF example, the following statement in a script file shows the Test Subchannel 2.

<A HREF="mctp://TEST/C2">Click Here to See Subchannel 2</A>

Referencing by MCTP is based on the channel identifier “TEST” and the subchannel identifier “C2,” not the channel script file. The appropriate CHANSCRIPT tag is located in the hierarchy to show the channel. The Script4.mcs script renders the “C2” subchannel, whereas Script3.mcs renders the “C1” subchannel.