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, as appears in scripts, 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. As a user navigates through the channel, he or she is effectively moving up and down through the CDF channel hierarchy accessing data files. At each level in the channel hierarchy, it is possible to associate a script to display the channel content, which is usually a list of subchannels or available items.

The CHANSCRIPT element identifies the script to be used to display the current channel location in a way 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 will be 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 previously defined CHANSCRIPT value.

Thus, an inheritance model is used. When it is necessary to render a particular subchannel, the nearest CHANSCRIPT element upward in the hierarchy is used to determine what 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 as best it can.

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, in conformance to the inheritance model, to show the channel. The script4.mcs script renders the "C2" subchannel whereas script3.mcs renders the "C1" subchannel.