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 in the following form:
mctp://CDFid/ItemId
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 and is used to scope the channel identifier to the correct CDF file. ItemId is the ID tag of the ITEM element for the 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 will be 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, which is the item for the script file, within the CDF.
ITEMSCRIPT elements can be children of either CHANNEL elements or ITEM elements. An ITEMSCRIPT determines the script to be used for all items of the current channel and its subchannels. An item script, as identified by ITEMSCRIPT, for a CHANNEL or ITEM element 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 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 data. The default item script simply enumerates through all the fields specified in the ITEMFORMAT tag and for each one displays the appropriate data from the specified MCD file. If the MCD file contains a repeating block, all the block values are enumerated on the page in a list until the end of the MCD file.
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 Iin order for an image to be rendered on IE4 desktop computer, you should reference images using standard HTTP references, rather than MCTP. If allowing the channel to be viewed on IE4 is not important, then the MCTP type URLs may be used. They will render correctly on the Windows CE-based device.