Click to return to the Content     
Web Workshop  |  Content & Component Delivery

Mobile Channels Overview


Preview Release (see note)
July 13, 1998

Contents
Creating Mobile Channels
Mobile Channels User Interface Elements

Mobile Channels provides a way to publish information on a Windows CE-based mobile device. A mobile channel can be thought of as a small-scale Web site designed specifically for offline browsing, and with the unique form factor and capabilities of a Window CE-based device in mind. A user can subscribe to a mobile channel through Internet Explorer 4.0 on their desktop computer. Then, they can synchronize the mobile channel content to their mobile device.

Windows CE adapts Internet Explorer 4.0 standards and technologies developed by Microsoft to support Mobile Channels. Internet Explorer 4.0 defines a standard for delivering information for offline Web browsing on a desktop computer. An Internet Explorer 4.0 channel is a self-describing Web site that contains all the necessary information to download Web content to a desktop computer. The Channel Definition Format (CDF) is a standard that contains meta information about a Web site. The CDF also contains instructions used by Internet Explorer 4.0 when downloading the site for offline browsing. Internet Explorer 4.0 defines the following three basic types of channels that all use standard CDF technology or CDF extensions:

The Mobile Channels technology introduces a fourth type of channel with its own extensions. A mobile channel is a Web site that conforms to the Mobile Channels CDF extensions. Mobile Channels provides the following benefits:

Mobile Channels technology embodies the following aspects:

TopBack to top

Creating Mobile Channels

The foundation of Mobile Channels rests on two key technologies: CDF and a subset of HTML.

A CDF file provides an inventory of items for Internet Explorer 4.0 to synchronize with a Windows CE-based device. Using a CDF file, you can be selective about which items are synchronized for offline browsing. While the Web site itself may have links to other content, the CDF file specifies only the pages and images available on the device. This specification reduces the amount of time and resources necessary for a computer to sync content.

The subset of HTML implemented for Mobile Channels provides tools for formatting and displaying quality Web content on Windows CE-based mobile devices. The subset includes support for tables, images, and various font styles. The Channel Browser on the device automatically resizes images for display on smaller screens. However, Mobile Channels provides a special META tag to override this automatic resizing. For more information about the Mobile Channels HTML subset, see Mobile Channels HTML Tag Reference.

In addition, Mobile Channels provides the pocket Active Server Pages (pASP) scripting language. This simple, client-size language provides capabilities similar to server-size scripting. You can use pASP to generate HTML pages from data templates.

TopBack to top

HTML Mobile Channels

The most common type of mobile channel features standard HTML. This type of channel is simply a set of HTML pages described by a CDF file, which describes the items that Internet Explorer 4.0 should download to the device for offline viewing. Users can also view this type of Mobile Channels Web site using any standard Internet browser. For more information about the subset of HTML that Mobile Channels supports, see Mobile Channel Design Guidelines.

The combination of HTML and the rich set of tools for page generation provide you with a great deal of flexibility. One such tool is Active Server Pages (ASP). Using ASP, you can generate unique HTML pages and CDF files for individual users. For example, a user selects their favorite movie theater listings from a movie theater mobile channel. This channel uses Active Server Page technology, which enables the ASP page to create and download a cookie to the user's Internet Explorer 4.0 application. The cookie notifies Internet Explorer 4.0 as to which movie theater listings the user views. Internet Explorer 4.0 then downloads only the movie listings for those specific theaters. Active Server Pages technology enables users to take only what they need from a mobile channel, thus decreasing download time and saving memory space, as well as increasing demand for your channel.

TopBack to top

Scripted Mobile Channels

A scripted mobile channel has three components: scripts, data, and a CDF file. A script defines a template that specifies the appearance and layout of a channel, subchannel, and item views. Scripts are written in a subset of Microsoft® Visual Basic® Script (VBScript). The scripting environment is similar to the scripting environment for Active Server Pages in Internet Information Server (IIS).

Data is typically a dynamic HTML file and formatted in a manner specific to the content. Data is packaged in simple text files for use with devices that have limited bandwidth and storage capacity. This data is readily accessible through the script.

Mobile Channels stores scripts, data files, and all content on the Windows CE-based device in a special-purpose cache. Browsers call URL references to the Mobile Channels Transport Protocol (MCTP). MCTP then invokes the script interpreter. In turn, the script interpreter accesses data and CDF files by running scripts. In this process, the script interpreter loads both scripts and data from the cache. The interpreter outputs pure HTML back to the MCTP and eventually to the Channel Browser application.

At display time, the Windows CE-based device executes the scripts to construct a HTML page. These pages render data in a browser using structural information contained in the CDF file. The CDF file is based on the Internet Explorer 4.0 CDF with additional Mobile Channels extensions. For more information on Mobile Channel CDF extensions, see Mobile Channel Extensions to CDF. To present an index to the user, the computer can access data items or additional subchannels through the CDF file. The browser can then retrieve item titles directly from the items.

This blending of scripts, data items, and CDF files is more complex than a standard channel or Web page. However, the combination yields more benefits when correctly applied. By separating the content into a template and data, Mobile Channels is able to deliver content in small segments instead of full HTML pages. This incremental approach results in the following:

TopBack to top

To create a scripted Mobile Channel

  1. Create a Mobile Channels CDF file that describes your channel content.
  2. Separate the content into Mobile Channels script files and Mobile Channels data files.
  3. Write script files that comply with the pASP protocol for the Windows CE-based device.
  4. Package incremental data, such as news articles or stock quotes, in one or more text files.

TopBack to top

Mobile Channels Extension to CDF

CDF is a standard for creating Active Channels in Internet Explorer 4.0, and is based on Extensible Markup Language (XML). Mobile Channels calls for additional tags to extend CDF. These additional tags optimize mobile channel performance on a Windows CE-based device, and are used by Mobile Channels to navigate through CDF files and to reduce the required storage space on a device. For more information about CDF, see the table of contents listing on the left.

TopBack to top

Top-level Channel URL

You use the path to the CDF in two attributes of the top-level CHANNEL element. The HREF attribute references the CDF path using MCTP. The SELF attribute references the CDF path using the standard HTTP prefix. Unlike the Internet Explorer 4.0 implementation, the SELF attribute is required in the top-level CHANNEL element.

The HREF attribute uses the MCTP prefix to identify the CDF file as a mobile channel. This results in special processing when referenced under Internet Explorer 4.0, where the mobile channel is registered for synchronization to the Windows CE-based device. Unlike the HREF attribute under Internet Explorer 4.0, in a mobile channel, the URL does not directly indicate the page to render. Rather, it references the top-level channel as specified by the CDF file. The appropriate CHANSCRIPT tag determines which HTML page is displayed first, or which script is used to render the top-level page of the channel. For more information about CHANSCRIPT, see CDF Tags for Mobile Channels.

The implementation of the BASE attribute is the same in Mobile Channels and Active Channels in Internet Explorer 4.0. The following code example shows that the attribute's URL is an HTTP URL.

<CHANNEL HREF="mctp://www.microsoft.com/test.cdf" ID="test"
 BASE = "http://www.microsoft.com/test/"
 SELF = "http://www.microsoft.com/test.cdf" />
    <ITEM HREF="START.HTM" ID="Start"/>
    <CHANSCRIPT VALUE="Start"/>
    ...
</CHANNEL>

In this code example, the CHANSCRIPT tag is used to specify the starting page by referencing the ID tag of the HTML page that is defined in the ITEM tag. The Start.htm file is the HTML page that serves as the topmost page of the channel.

In the mobile channel CDF file, the HREF for the CHANNEL tag is the only one that has an MCTP-style URL. All other HREF values begin with HTTP.

TopBack to top

Extensions to Standard Tags and Attributes

Mobile Channels recognizes several attributes and attribute values that may appear in standard CDF tags. These tags are described in the following table.

Tag/Attribute Description
ID A short string identifier for the CHANNEL, ITEM, and LOGO elements.
DEFAULTPREF A Boolean operator indicating the suggested preference setting for a CHANNEL element. It can be "On" or "Off." The default, if not specified, is "On."
USAGE New values for Mobile Channels are MobileChannel and MobileDesktopComponent.
CHANNEL CHANNEL element may take a USAGE tag specifying either of the two new USAGE values. It is required for the top-level CHANNEL element of a Mobile Desktop Component.

Each tag or attribute is discussed in detail in the following list:

ID

An ID tag is a text string used as an attribute to identify the specified element. An ID tag must be provided for all CHANNEL, and ITEM elements, and optionally for LOGO elements, in a mobile channel.

ID="ChanId"
ID="ItemId"
ID="LogoId"

An ID tag is used for short references of a mobile channel element both within a CDF and within scripts. Within the CDF, the ID tag is used as a value for both CHANSCRIPT and ITEMSCRIPT tags to refer to the associated ITEM tag that represents the script file.

Within a script, the ID tag is used, along with the MCTP syntax, to form unique URLs in the Mobile Channels namespace. The ID tag is used in the MCTP transport to uniquely reference a channel or item. MCTP references are of the form "mctp://CDFid/ChanID" for a channel or "mctp://CDFid/ItemID" for an item.

In a CDF file, the ID tag of the top-level channel is used as a handle to the channel. The maximum length of the ID string is 64 characters. To conserve network bandwidth and storage space, a unique handle of between 6 and 10 characters is recommended for the top-level ID. The following code examples show how to define ID strings.

<CHANNEL ID="Sports" >
<ITEM HREF="http://www.microsoft.com/test/sports/article001.mcd"
        ID="Art1" >
<LOGO HREF="http://www.microsoft.com/test/sports/sportslogo.gif"
     STYLE="IMAGE"
        ID="L_Sports" >

The ID tag is required for each parent element and can be of a single occurrence. There are no applicable child elements for this tag.

USAGE

For the USAGE tag, Mobile Channels defines the following two new values:

MobileChannel

The statement

<USAGE VALUE="MobileChannel"/>

specifies the channel as a mobile channel, or an item as a special Mobile Channels data item. The top-level channel should be given a USAGE value of "MobileChannel." When the USAGE value is set to "MobileChannel," Mobile Channels items are seen on Channel Explorer on the device but not on the Channel Bar of Internet Explorer 4.0. This feature makes it possible to properly display the items as the special MCD files on the device and to ignore them in Internet Explorer 4.0. For example,

<ITEM HREF="http://www.microsoft.com/test1.mcd" ID="T1">

<USAGE VALUE="MobileChannel"/>

</ITEM>

<ITEM HREF="http://www.microsoft.com/test2.mcs" ID="T2">

<USAGE VALUE="None"/>

</ITEM>

Item T1 is a Mobile Channels data item and is seen in the Channel Explorer feature on the device, but not by Internet Explorer 4.0 on the desktop computer. Item T2 is a Mobile Channels script and is not seen by either Internet Explorer 4.0 or the Channel Explorer on the device. The USAGE tag has no applicable child element.

To save storage space, use the statement

<USAGE VALUE=""/>

instead of its equivalent,

<USAGE VALUE="None"/>

MobileDesktopComponent

The statement

<USAGE VALUE="MobileDesktopComponent"/>

specifies the channel as a Mobile Channels Desktop Component. On a Windows CE-based device, only use this valve when making the channel available as a component for the device's Active Desktop, as in the following code example.

<CHANNEL HREF="http://www.mydomain.com/myChannel.cdf">

<USAGE VALUE="MobileDesktopComponent"/>

</CHANNEL>

The channel, as specified by "myChannel.cdf," can be registered as a component for the device's Active Desktop.

There can be only one occurrence of this value in a specified desktop component CDF file. There are no applicable child elements.

DEFAULTPREF

The DEFAULTPREF tag is used as follows:

<CHANNEL ID="ChanId">
     <DEFAULTPREF VALUE="ON"|"OFF"/>
</CHANNEL>

The tag marks a subchannel with specific default preferences. You can use this attribute to control which subchannels a user receives content for by default. For example, when a new channel is synchronized to a Windows CE-based device, items within subchannels marked with the attribute DEFAULTPREF VALUE="OFF" are not transferred.

This mechanism allows you to create a channel that offers more content than can reasonably be accommodated by the limited storage resources available on a Windows CE-based device, and yet does not overwhelm the device with all of this content. The DEFAULTPREF setting is applied only when the channel is first synchronized to the device. After this, users can change their preferences to include more or less content than the DEFAULTPREF settings allow.

The DEFAULTPREF tag can have values of either "ON" or "OFF." If DEFAULTPREF attribute is not specified, the Windows CE-based device treats the subchannel as if it were marked with DEFAULTPREF VALUE="ON."

For example:

<CHANNEL ID="SubChan1">
    <DEFAULTPREF VALUE="OFF"/>
    …
</CHANNEL>

The DefaultPref tag should appear only once in a CHANNEL element.

TopBack to top

CDF Tags for Mobile Channels

Additional tags recognized by Mobile Channels are described in the following table.

Tag Description
CHANSCRIPT Identifies the ID of the script file to render the channel and subchannels.
ITEMSCRIPT Identifies the ID of the script file to render the item data file.
ITEMFORMAT Defines the file structure for data files.

The following list documents each tag in detail:

CHANSCRIPT

The CHANSCRIPT tag is used as follows:

<CHANSCRIPT VALUE="ChannelID"/>

The CHANSCRIPT tag specifies an HTML page or a Mobile Channels script (MCS) that displays a channel. The CHANSCRIPT tag value applies to all child channels of the current channel or subchannel. Thus, every subchannel must have its own CHANSCRIPT tag unless the subchannel is script-generated and the associated script is capable of generating multiple views. This tag supersedes the CHANSCRIPT value previously defined by a parent CHANNEL element, if any exist. The VALUE attribute specifies the ID of the ITEM element corresponding to the script that renders this level of the channel. For example,

<CHANSCRIPT VALUE="ChanScript1"/>

where the channel script identified by "ChanScript1" has been defined elsewhere in the CDF file, say, as follows:

<ITEM HREF="http://www.microsoft.com/channel.mcs" ID="ChanScript1">
    <USAGE VALUE="None"/>
</ITEM>

The top-level CHANNEL element can have at least one CHANSCRIPT tag as the child element. Each subchannel can have, at most, one such tag.

ITEMSCRIPT

The ITEMSCRIPT tag is used as follows:

<ITEMSCRIPT VALUE="ItemID"/>

The ITEMSCRIPT tag specifies a script that renders the display of MCD items. ITEMSCRIPT is only used for scripted channels. The ITEMSCRIPT tag value applies to all child items of the current channel or subchannel. This tag supersedes the ITEMSCRIPT value previously defined by a parent CHANNEL element, if any exist. The VALUE attribute specifies the ID of the ITEM element corresponding to the script that renders this level of the channel. For example:

<ITEMSCRIPT VALUE="A_Script"/>

The item script file here refers to the following ITEM element defined elsewhere in the CDF file as:

<ITEM HREF="http://www.microsoft.com/items.mcs" ID="A_Script">
    <USAGE VALUE="None"/>
</ITEM>

You can set the VALUE attribute to "None" or "" for the USAGE tag to prevent the script file from appearing in the Channel Explorer.

The topmost CHANNEL element can have at least one ITEMSCRIPT tag. At all other channel levels there can be, at most, one such tag.

ITEMFORMAT

The ITEMFORMAT tag is used as follows:

<ITEMFORMAT VALUE="header_block ; repeat_block"/>

The tag specifies the format of a class of MCD items by identifying the associated file structure. ITEMFORMAT is only used for scripted channels. MCD items are simple text files that can have a unique header and a repeating block structure for record-oriented data. Special helper functions are provided in the scripting environment to access the MCD content using information contained in the ITEMFORMAT tag. Both header_block and repeat_block are optional, but at least one of them must exist. If only a repeat_block exists, it must be preceded by the semi-colon (;). The header block typically contains the description about the items. The repeatable data block contains description about items. The header_block and repeat_block are of the following form:

v1[=t1], v2[=t2], … , vi[=ti]

Here, vi is the field name of the block value and ti is the optional type of the block value. If ti is omitted, the default value "HTML" is assumed. Valid types are described in the following table.

Type Description
HTML HTML text including markup
TEXT Same as HTML but without markup
IMG ID of image item in CDF files
HREF URL to a page, for example, a data file or channel script

A data block is merely a group of values, with one value per line. Any meaningful data file should have at least one data block. For example, three data blocks might be used to show a portfolio of three stocks. The following code example shows how the Market mobile channel displays stock values listed in the Stocks.mcd file. The header gives the title and displays the date of the shown stocks. The data to be listed includes the name, the low price, high price, and closing prices of each stock.

<ITEM HREF="http://www.microsoft.com/Stocks.mcs" ID="Stock_S">
   <USAGE VALUE="None"/>
</ITEM>
. . .
<CHANNEL ID= "Stock_C">
   <TITLE>Market</TITLE>
   <ITEM HREF="http://www.microsoft.com/Stocks.mcd" ID="Stock_D">
       <USAGE VALUE="MobileChannel"/>
       <ITEMSCRIPT VALUE="Stock_S"/>
       <ITEMFORMAT VALUE ="Title,Date,Picture=IMG;
                          Name,Low,High,Close"/>
   </ITEM>
</CHANNEL>

Here, the header block has three values, Title, Date, and Picture, and the data block has four: Name, Low, High, and Close.

IMG indicates the field that represents an image, such as a JPEG or GIF file. The field value is the identifier of the item defining the URL of the image. The built-in item script creates an IMG value to display this item.

The data block may be repeated to build a table of stock prices. If the Stocks.mcd file contains a single data block, the script displays a single stock per page. If it has multiple data blocks, the script could display a table of stocks.

The following code example — which represents a news article with a title, an image, and the body of text — shows that the repeat block can be omitted.

<ITEMFORMAT VALUE="TITLE, PICTURE=IMG, BODY;"/>

The following code example — which represents a page with stock listings — shows that the header block can be omitted. The semi-colon (;) is used to indicate the value list; it is the repeat block and not a header block.

<ITEMFORMAT VALUE =";Name, Low, High, Close"/>

TopBack to top

CDF Omissions

Not all the standard Internet Explorer 4.0 tags are supported in Mobile Channels. In particular, Mobile Channels does not support any Software Update Channel tags. In addition, the Mobile Channels parser ignores the LOGIN tag. However, while the EARLIESTTIME, INTERVALTIME, and LASTTIME tags are ignored on the device, they are supported on the desktop computer and used by Internet Explorer 4.0 to download updates for the channel from the Web.

TopBack to top

Mobile Channels Data Files

Data files are used to deliver incremental data for a channel, and are only used in scripted channels. Data files are simple text files that contain data with one item per line in the file. Within the CDF file, a structure for the data file may be declared using an ITEMFORMAT tag, as discussed earlier.

Each data file must have a .mcd extension. The CDF file must include an ITEM tag to define the MCD file. Within the ITEM tag, the ID attribute is used as a shorthand reference for the MCD file from within a script without having to reference its complete URL.

Unlike the conventional approach, where script files are run and call for data to display, Mobile Channels does the opposite for displaying incremental data. Because new information can come in at any time within a new MCD file, it is more efficient to activate the script to display data when it arrives. An added benefit of this alternate approach is that it permits the inheritance of scripts.

The file format for data files is flexible. It is simply a text file that contains the data, such as references to images, with each item on a separate line. Mobile Channels exposes methods within the scripting environment for reading this content from the file.

The ITEMFORMAT tag is used to specify the type of data present in the file. Generally, files have the following format:

[Header Block]
[Data Block 1]
[Data Block 2]
. . .
[Data Block n]

Each block may consist of zero or more fields, as specified in the ITEMFORMAT. This allows a single data file to be used as a simple database that can have rows of data. Data items are organized in the structure, as specified by the following ITEMFORMAT tag:

<ITEMFORMAT VALUE="TITLE,DATE,PICTURE=IMG;NAME,LOW,HIGH,CLOSE"/>

The first block is the header block, which contains general information such as a title, date, and image. The remaining repeating data blocks follow the header block.

Note The different blocks are commented for the purpose of illustration. Comments should not be present in any MCD file. There should be a carriage return at the end of each data file.

Stock Info                  'header block
April 24, 1997
ClintonPic
MSFT                        'data block 1
110.25
112.50
111.00
DEC                         'data block 2
21
23
22
IBM                         'data block 3
132.50
132.75
132.75

TopBack to top

Mobile Channels Script Files

Mobile Channels employs two types of scripts: channel scripts and item scripts. In the CDF, a CHANNELSCRIPT tag identifies a script for a channel and an ITEMSCRIPT tag identifies a script for an item. All Mobile Channels script files end with an .mcs extension.

Scripts are invoked in a data-driven manner. When it is time to display a particular data file, the reference is made to the data file and the appropriate item script is located to display it. Likewise, when it is time to show channel content, such as a listing of subchannels or data items, the reference to the channel is made and the appropriate channel script is located to display it. For more information on how scripts are associated with the data or channels, see Item Script Selection and Channel Script Selection.

The following code example shows a CDF file that is referenced later in this chapter.

<!-- Declare item scripts ––>
<ITEM HREF="http://www.microsoft.com/test/script1.mcs" ID="IS1">
    <USAGE VALUE="None"/>
</ITEM>
<ITEM HREF="http://www.microsoft.com/test/script2.mcs" ID="IS2">
    <USAGE VALUE="None"/>
</ITEM>

<!-- Declare channel scripts -->
<ITEM HREF="http://www.microsoft.com/test/script3.mcs" ID="CS1">
    <USAGE VALUE="None"/>
</ITEM>
<ITEM HREF="http://www.microsoft.com/test/script4.mcs" ID="CS2">
    <USAGE VALUE="None"/>
</ITEM>

<CHANNEL HREF = "http://www.microsoft.com/test/test.cdf" ID="test">
   <TITLE>Test Channel</TITLE>
   <!-- IS1 is the general item script to use within the channel -->
   <ITEMSCRIPT VALUE="IS1"/>

   <!--CS1 is the general channel script to use within the channel -->
   <CHANSCRIPT VALUE="CS1"/>
    . . .
   <CHANNEL ID="C1">
      <TITLE>Test Subchannel 1</TITLE>

      <!-- This channel is rendered by the general channel script CS1-->
      . . .
      <ITEM HREF="http://www.microsoft.com/test/item-a.mcd" ID="ITA">
          <!-- This item is rendered by the item-specific IS2 script-->
          <ITEMSCRIPT VALUE="IS2"/>
          <USAGE VALUE="MOBILECHANNEL"/>
      </ITEM>
      . . .
   </CHANNEL>
   <CHANNEL ID="C2">
      <TITLE>Test Subchannel 2</TITLE>

      <!--This channel is rendered by the channel-specific script CS2-->
      <CHANSCRIPT VALUE="CS2" />
      <ITEM HREF="http://www.microsoft.com/test/item-b.mcd" ID="ITB">
          <!--This item is rendered by the general IS1 item script-->

          <USAGE VALUE="MobileChannel"/>
      </ITEM>
   </CHANNEL>
</CHANNEL>

TopBack to top

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. 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 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 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.

TopBack to top

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

TopBack to top

Scripting

A script specifies the layout and behavior of HTML pages. Script segments are enclosed between the <% and %> or <%= and %> delimiter pairs. The latter pair of delimiters entails special use and meaning in the script file. In each script segment, there must be at least one valid executable, or non-comment, statement. There must also be at least one scripting segment in the .mcs file. Any empty script segment generates a syntax error. Scripting segments can be freely intermixed with standard HTML text, provided that the script-generated HTML output has the valid syntax within the context of the standard HTML display code.

TopBack to top

Example Channel Script

<HTML>
<%
  Set MC   = Server.CreateObject("MobileChannels.Utilities")
  URL    = Request.ServerVariables("URL")
  DataID   = Request.QueryString("DATAID")
  Pieces   = Split(URL,"/")
  ChanID   = Pieces(2)

' Get logo and title of channel
  TopElem = MC.Locate(ChanID)
  ChanTitle = ""
  LogoHref = 0
  If TopElem Then
    ChanTitle = MC.Title(TopElem)
    LogoElem = TopElem
    LogoElem = MC.Navigate(LogoElem, "INMATCH", "LOGO")
    Do While LogoElem
      LogoStyleElem = MC.Navigate(LogoElem, "INMATCH", "STYLE")
      If LogoStyleElem Then
        If StrComp(MC.Value(LogoStyleElem), "IMAGE", 1) = 0 Then
          LogoHref = MC.Href(LogoElem)
          If LogoHref Then
            If MC.HrefExists(LogoHref) Then
              Exit Do
            Else
              LogoHref = 0
            End If
           End If
        End If
      End If

      LogoElem = MC.Navigate(LogoElem,"NEXT")
      If LogoElem Then
        LogoElem = MC.Navigate(LogoElem,"MATCH","LOGO")
      End If
    Loop
  End If

  NeedTitle = 1
  Response.Write("<HEAD><TITLE>" & ChanTitle & "</TITLE></HEAD>")
  If LogoHref Then
     Response.Write("<BODY><A HREF=mctp://" & ChanID & ">
       <IMG SRC=" & LogoHref & "></A><BR>&nbsp;<BR>")
  ElseIf ChanTitle And Len(ChanTitle) Then
     Response.Write("<BODY><A HREF=mctp://" & ChanID & ">
       <H3>" & ChanTitle & "</H3></a>")
     NeedTitle = 0
  Else
    Response.Write("<BODY>")
  End If

  ' Decide whether you need a title for this chan/subchan
  If DataID And (DataID <> ChanID) Then
    NeedTitle = 1
  Else
    DataID = ChanID
  End If

  SubTitle = 0
  SubElem = MC.Locate(DataID)
  If SubElem Then
    SubTitle = MC.Title(SubElem)
    If SubTitle And NeedTitle Then
      Response.Write("<B>" & SubTitle & "</B><BR>&nbsp;<BR>")
    End If

    ' Display contents of chan/subchan
    Response.Write("<TABLE BORDER=0 ")
    Response.Write("CELLPADDING=-2 CELLSPACING=-2>")
    ChildElem = MC.Navigate(SubElem,"IN")
    Do While ChildElem
      ShowIt = 1
      IsChan = 0
      If MC.Tag(ChildElem) = "CHANNEL" Then
        IsChan = 1
        If Not MC.IsSubscribed(ChildElem) Then
          ShowIt = 0
        End If
      ElseIf MC.Tag(ChildElem) = "ITEM" Then
        VisParElem = MC.Navigate(ChildElem,"INMATCH","USAGE")
          If VisParElem Then
            Usage = MC.Value(VisParElem)
              If Usage Then
                If StrComp(Usage,"NONE",1) = 0 Then
                  ShowIt  = 0
                End If
               End If
          End If
          ' Be sure item exists
          If ShowIt Then
            ChildHref = MC.Href(ChildElem)
            If ChildHref Then
              If Not MC.HrefExists(ChildHref) Then
                ShowIt = 0
              End If
            Else
              ShowIt = 0
            End If
          End If
      Else
        ShowIt = 0
      End If

      If ShowIt Then
      ' Be sure you can get the ID
      IDVal = 0
      IDElem = MC.Navigate(ChildElem,"InMatchINMATCH","ID")
        If IDElem Then
          IDVal = MC.Value(IDElem)
        End If
        If Not IDVal Then
          ShowIt = 0
        End If
      End If
    ' Get title
    If ShowIt Then
      ItemTitle = MC.Title(ChildElem)
      If Not ItemTitle Or (Len(ItemTitle) = 0) Then
        ShowIt = 0
      Else
        If Len(ItemTitle) > 26 Then
          ItemTitle = Mid(ItemTitle,0,25) & "…"
        End If
      End If
    End If
    ' You know what it is and are going to try to show it
    If ShowIt Then
      If IsChan Then
        Response.Write("<TR><TD>*")
      Else
        Response.Write("<TR><TD>")
      End If
      Response.Write("<TD>&nbsp;<a href=mctp://" & ChanID & "/"
         & IDVal & ">" & ItemTitle & "</A>")
    End If

    ChildElem = MC.Navigate(ChildElem,"NEXT")
    Loop
    Response.Write("</TABLE>")
  Else
    Response.Write("Data ID not found.")
  End If
%>

<BR>&nbsp;<BR><HR>
<B>Note:</B> This page was automatically generated because the
correct scripts could not be found.  If this problem persists
after synchronization, please contact the content provider.
</BODY>
</HTML>

TopBack to top

Example Item Script

<HTML>

<%
  Set MC   = Server.CreateObject("MobileChannels.Utilities")
  URL      = Request.ServerVariables("URL")
  DataID   = Request.QueryString("DATAID")
  Pieces   = Split(URL,"/")
  ChanID   = Pieces(2)

  ' Get logo and title of channel
  TopElem = MC.Locate(ChanID)
  ChanTitle = ""
  LogoHref = 0
  If TopElem Then
    ChanTitle = MC.Title(TopElem)
    LogoElem = TopElem
    LogoElem = MC.Navigate(LogoElem, "INMATCH", "LOGO")
  Do While LogoElem
    LogoStyleElem = MC.Navigate(LogoElem, "INMATCH", "STYLE")
      If LogoStyleElem Then
        If StrComp(MC.Value(LogoStyleElem), "IMAGE", 1) = 0 Then
          LogoHref = MC.Href(LogoElem)
            If LogoHref Then
              If MC.HrefExists(LogoHref) Then
                Exit Do
              Else
                LogoHref = 0
              End If
            End If
        End If
      End If
    LogoElem = MC.Navigate(LogoElem, "NEXT")
    If LogoElem Then
      LogoElem = MC.Navigate(LogoElem, "MATCH", "LOGO")
    End If
  Loop
  End If

  Response.Write("<HEAD><TITLE>" & ChanTitle & "</TITLE></HEAD>")
  If LogoHref Then
    Response.Write("<BODY><A HREF=mctp://" & ChanID & ">
      <IMG SRC=" & LogoHref & "></A><BR>&nbsp;<BR>")
  ElseIf ChanTitle And Len(ChanTitle) Then
    Response.Write("<BODY><A HREF=mctp://" & ChanID & ">
      <H3>" & ChanTitle & "</H3></A>")
  Else
    Response.Write("<BODY>")
  End If


' Dump article out as best you can
  ArtElem = 0
  If DataID Then
      ArtElem = MC.Locate(DataID)
  End If
  If ArtElem Then
  For Blk=0 To 100
    Data = MC.Data(ArtElem,Blk)
    If Not Data.Count Then
      Exit For
    End If
  For Field=0 To Data.Count - 1
    Tag = Data(Field).Tag
    Val = Data(Field).Value
    Type = Data(Field).Type
    If Val And Len(Val) Then
      If (StrComp(Type,"HTML",1) = 0) Or (StrComp(Type,"TEXT",1)
         =  0) Then
' Output text in standard html
        If Tag And Len(Tag) Then
          Response.Write("<B>" & Tag & ": </B>")
        End If
        Response.Write(Val & "<BR>")
      ElseIf StrComp(Type,"IMG",1) = 0 Then
        ' Try to create an image
        ImgElem = MC.Locate(Val)
          If ImgElem Then
            ImgHref = MC.Href(ImgElem)
            If ImgHref Then
              Response.Write("<IMG SRC=" & ImgHref
                & "><BR>")
            End If
          End If
      ElseIf StrComp(Type,"HREF",1) = 0 Then
' Write an href
      Response.Write("<A HREF=" & Val & ">" & Tag & "</A><BR>")
      End If
    End If
  Next
  Next
  End If
%>

<BR>&nbsp;<BR><HR>
<B>Note:</B> This page was automatically generated because the
correct scripts could not be found.  If this problem persists
after synchronization, please contact the content provider.
</BODY>
</HTML>

TopBack to top

Mobile Channels User Interface Elements

Mobile Channels user interface elements include the Channel Browser and Active Desktop, as well as control panels for changing settings for channel synchronization. The following discussion focuses on how to properly implement these elements.

TopBack to top

Channel Synchronization

As a synchronizing agent, Microsoft Windows CE Services copies mobile channel contents into the channel cache of the Windows CE-based device. Channel synchronization is a two-way operation. From the desktop computer to the device, the synchronization agent copies channel content, such as CDF, scripts, data, and images. The agent posts the usage logging data to the logging host site from the device to the desktop computer.

When the agent synchronizes mobile channels, it checks a list of subscribed channels that a user can select from the Channel Synchronization Options panel. The list covers the subscribed channels with associated CDF files on both the desktop computer and the device. The CDF files must have the top-level channels defined with the following USAGE tag:

<USAGE VALUE="MobileChannel"/>

TopBack to top

Channel Browser

A user launches Channel Browser to select and view a mobile channel. The Channel Browser uses a CDF file to determine what content do display to the user. Therefore, the Channel Browser can only display pages described by a CDF file. Channel Browser's main window holds a command bar, a Channel Bar, and an HTML control. The command bar features a menu and a toolbar. The Channel Bar displays icons of subscribed channels. The icon files can be of the GIF or JPEG format. The following code example shows how to specify the icons in CDF files using the LOGO tag with STYLE setting to "ICON."

<LOGO STYLE="Icon"
  ID="icon1"
  HREF="http://www.microsoft.com/MobileChannels/icon1.gif"/>

The HTML control displays the content for the current channel. You are responsible for supplying the content, specifying page layout, and providing the navigation scheme from within the channel. Except for a smaller screen size, Channel Browser is modeled after the Internet Explorer 4.0 browser on a desktop computer. This similarity provides a consistent Web experience for Windows CE users.

Channel Browser includes Home Channel, a virtual channel at the top of the channel hierarchy that you can see in Channel Explorer. Home Channel contains links to the main pages of all subscribed channels. A built-in, automatically generated Home Channel HTML page displays the subscribed channels. Users can access this channel using the Home Channel command from either the Go menu or the appropriate button on the toolbar.

From the Go menu of Channel Browser, a user can choose Explore Channel to bring up the Channel Explorer dialog box. This pop-up window provides a hierarchical view of the mobile channels. It offers users a shortcut to channel navigation without having to trace through all the intermediate pages. Each channel and item may have an icon associated with it. Top-level channels are listed in order, as specified in Preferences. Within a channel, the subchannels and items are listed according to the hierarchy specified in the CDF file. The icon displayed at each level is derived from the LOGO tag in CDF, as explained earlier. If you fail to supply a logo, the default channel or item icon is used. The TITLE tag specifies the name of each channel, as shown in the following code example.

<CHANNEL>
   <TITLE>Mobile Channel Tips</TITLE>
    …
</CHANNEL>

By choosing the Properties command on the File menu of Channel Browser, a user can examine item properties from the Item Properties panel for any item page displayed in the browser. The information, including the title of the item and the date of creation and last modification, is extracted from the CDF file defining the item.

TopBack to top

Active Desktop

The Active Desktop for a Windows CE-based device shares many features with Channel Browser and uses the underlying Mobile Channels infrastructures. Its main window uses HTML controls to display the system information and selected shortcuts to applications. Each control represents a desktop component. On a Windows CE-based device, such as the Palm-size PC, Active Desktop components typically include the Windows CE Logo, Owner Information, Appointments, Tasks, Messages, and custom desktop components. Tapping the Appointment component launches the Calendar application. Similarly, the Tasks and Messages items provide shortcuts to the Tasks and Inbox applications, respectively.

The following code example for a sample Stock Market component shows that each desktop component is driven by a Mobile Channels script that you can supply.

<HTML>

<HEAD>
<META
  HTTP-EQUIV="Content-Type"
  CONTENT="text/html; charset=iso-8859-1">
<META
  HTTP-EQUIV="Notify"
  CONTENT="CACHEUPDATE=http://Market/Stocks/Stocks.mcd;
    URL=mctp://Stocks">

<TITLE>Stock Quotes</TITLE>
</HEAD>

<BODY BGCOLOR=#FFFFFF>

<%
SET MC = Server.CreateObject("MobileChannels.Utilities")

' Get the small logo image from the CDF
Base = MC.Navigate("", "INMATCH", "BASE")
LogoElem = MC.Navigate("", "INMATCH", "LOGO")
Logo = MC.Navigate(LogoElem, "INMATCH", "HREF")
LogoImg = MC.Value(Logo)
IF Base THEN LogoImg = MC.Value(Base) & LogoImg END IF

' Jump to the data reference in the CDF
DataElem = MC.Locate("D1")

' Create a table of SYMBOL/VALUE/CHANGE for each stock
Response.Write("<TABLE CELLPADDING=-1 CELLSPACING=-1>")
Response.Write("<TBODY>")

RecordNum = 1
Record = MC.Data(DataElem, RecordNum)

DO WHILE Record.Count
  Response.Write("<TR VALIGN=BOTTOM>")

  ' Show the logo (from the CDF)
  IF RecordNum = 1 THEN
    Response.Write("<TD><IMG SRC=" & LogoImg & "></TD>")
  Else
    Response.Write("<TD></TD>")
  END IF

  Response.Write("<TD>" & Record(0).Value & "</TD>")
  Response.Write("<TD ALIGN=RIGHT>&nbsp;$" & ")
  Response.Write(Record(1).Value & "</TD>")
  Response.Write("<TD ALIGN=RIGHT>&nbsp;$" & )
  Response.Write(Record(2).Value & "</TD>")
  Response.Write("</TR>")

  RecordNum = RecordNum + 1
  Record = MC.Data(DataElem, RecordNum)
LOOP

Response.Write("</TBODY>")
Response.Write("</TABLE>")

' Show the user when the data was last updated (from data file)
Record = MC.Data(DataElem, 0)
IF Record.Count THEN
  Response.Write("<HR><I>Last Updated</I>: " )
  Response.Write(Record(0).Value & " at " & Record(1).Value)
END IF

%>

</BODY>
</HTML>

You create a desktop component in a CDF file and define the desktop component as a child element of a channel. To do this, you must use the following tag in the CDF file containing the desktop component:

<USAGE VALUE="MobileDesktopComponent"/>

Any such script is appropriately registered as a desktop component. The script files are then fed into the MCTP transport to process the data into the HTML format for display in the viewer. All the usual HTML tags are allowed.



Back to topBack to top

Did you find this material useful? Gripes? Compliments? Suggestions for other articles? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.