Item Script Selection

When it is necessary to render a particular data file in the browser, the appropriate script must be selected. Item scripts are responsible for rendering MCD data files and are invoked as a result of referencing the URL of the data file. The appropriate script is selected based upon the proximity of an ITEMSCRIPT tag to the particular MCD data file.

An item URL, as appears in scripts, is of the following form.

mctp://CDFid/ItemId 

Here, “mctp://” specifies the use of MCTP to resolve the URL and to invoke the scripting engine. CDFid is the ID tag of the top-level CHANNEL element and is used to scope the channel identifier to the correct CDF file ItemId is the ID tag of the ITEM element that represents MCD data file to be rendered.

The MCD data file appears in an ITEM element within the channel hierarchy. The location of the ITEM element relative to an ITEMSCRIPT element determines which script is used to render the data. The script file is identified by matching the ID value in the ITEMSCRIPT element with the ID value of an ITEM element within the CDF.

ITEMSCRIPT elements can be children of either CHANNEL elements or ITEM elements. An ITEMSCRIPT element determines the script to be used for all items of the current channel and its subchannels. An item script for a CHANNEL or ITEM element, as identified by ITEMSCRIPT, supercedes any previously defined ITEMSCRIPT value.

Thus, an inheritance model is used. When it is necessary to render a particular MCD item, the nearest ITEMSCRIPT element in the hierarchy is used to determine which script should render the data. If the appropriate script is not available on the device, a built-in script is used to render the data. The default item script enumerates through all the fields specified in the ITEMFORMAT tag. For each item, the default script displays the appropriate data from the specified MCD file. The script also enumerates all repeating block values to a list; this list is then displayed on the mobile channel page.

By convention, item scripts are specified at the top level of a channel, usually at the top of the file. Each item script is assigned a unique ID. The script can then be referenced, using an ITEMSCRIPT element, from any location in the CDF hierarchy. In a script, data links are anchored using a regular HREF link to the MCTP transport, rather than the usual HTTP protocol.

Given the previous CDF example, the following statement in a script file shows the data in the Item-a.mcd file.

<A HREF="mctp://TEST/ITA">Click Here to See Item A</A>

Referencing by MCTP is based on the channel identifier “TEST” and the data file identifier “ITA,” not the item script file. The appropriate ITEMSCRIPT tag is sought in the hierarchy to show the data. This conforms to the inheritance model. The Script1.mcs script renders the Item-b.mcd file, whereas Script2.mcs renders the Item-a.mcd data file.

Note   In order for an image to be displayed on a desktop computer using Internet Explorer 4.0, you should reference images using standard HTTP references, rather than MCTP. You can use MCTP references if the image must be viewed on a Windows CE-based device, but not necessarily on Internet Explorer 4.0.