Statexml

<FL:smarttaglist xmlns:FL="urn:scherras-rrncrosoft-com:srrarttags:list"> <FL:name>Explore the States</FL:name> <FL:description>Shows detailed state info</FL:description> <FL:updateable>false</FL:updateable> <FL:updatefrequency>10080</FL:updatefrequency> <FL:autoupdate>true</FL:autoupdate>

<FL:smarttag type="urn:scherras-rrncrosoft-com:office:smarttags#States"> <FL:caption>State Explorer</FL:caption> <FL:terms>

<FL:termlist>"mt", "sd", "ny", "ca", "oh", "ne", "ar", "md", _ "fl", "ga"</FL:termlist> </FL:terms> <FL:actions>

<FL:action id="StateLookup"> <FL:caption>View State Information</FL:caption> <FL:url>http://www.americaslibrary.gov/cgi-bin/page.cgi/ _ es?subject={TEXT}</FL:url> </FL:action>

<FL:action id="MoreInfo"> <FL:caption>More State Info</FL:caption> <FL:url>http://www.ipl.org/div/kidspace/stateknow/ _ {TEXT}1.html</FL:url> </FL:action> <FL:action id="Facts">

<FL:caption>Did You Know...</FL:caption> <FL:url>http://www.ipl.org/div/kidspace/stateknow/ _ {TEXT}2.html</FL:url> </FL:action> </FL:actions> </FL:smarttag> </FL:smarttaglist>

The XML code that you have just entered describes your smart tag using a specific syntax defined by Microsoft. As mentioned in Chapter 17, the XML document begins by specifying a root element and declaring a namespace. The namespace is stated in the form of the Uniform Resource Indicator (URI) to uniquely identify a group of XML tags belonging to a logical category. For smart tags, the "urn:schemas-microsoft-com:smarttags:list" URI is used. Notice that this name is preceded by an alias "FL'—a short name for this namespace. The root element is named smarttaglist. This element is contained within the FL namespace. Therefore, each smart tag list that you develop using XML should begin with:

<FL:smarttaglist xmlns:FL="urn:schemas-microsoft-com:smarttags:list">

and end with a closing tag:

</FL:smarttaglist>

Once you've declared a smart tag, you need to specify certain properties, such as a friendly name for the smart tag recognizer:

<FL:name>Explore the States</FL:name>

The name element is required. The optional description element is a longer string describing the smart tag:

<FL:description>Shows detailed state info</FL:description>

The optional elements, such as updateable, updatefrequency, and autoupdate, as well as lastcheckpoint, lastupdate, and updateurl (not specified here), tell if the smart tag list can be updated, and if so, how often the update should occur, when the last update occurred, and which URL to check for updates to the smart tag list. The default value of updatefrequency is 10,080 minutes (seven days). The State Explorer smart tag uses some of these elements for demonstration only. Our term list will not be updatable as coded here. To recognize more states, you will have to manually add new state abbreviations to the term list, save the modified XML file, and relaunch Excel before your changes can take effect. To find out how you can replace one smart tag list with another on a scheduled basis, check this topic in the Smart Tag software development kit (Smart Tag SDK).

A smart tag type is defined by a unique namespace in the form of a URI and a tag name, as in the following line of code:

<FL:smarttag type="urn:schemas-microsoft-com:office:smarttags#States">

The smart tag element is absolutely required. In the above line, "urn:schemas-microsoft-com:office:smarttags" is the name of the namespace and "States" is the tag name. The tag name is always preceded with the "#" symbol. The tag name can be any unique string.

After the definition of the smart tag type, you need to define the caption and terms for the tag type. For example:

<FL:caption>State Explorer</FL:caption> <FL:terms>

<FL:termlist>"mt", "sd", "ny", "ca", "oh", "ne", "ar", "md", _ "fl", "ga"</FL:termlist> </FL:terms>

The caption is what will appear at the top of the Smart Tag Actions menu when the user clicks the Smart Tag button. The terms element can be one of the following: a termlist or a termfile. A termlist is a comma-delimited list of terms. Double quotes denote that the terms are case-sensitive. The specified state abbreviations will be recognized only when typed in lowercase. A termfile is a special binary file (.bin) containing your terms. Microsoft offers two utilities (MakeTrie and TestTrie) that can be used to prepare such a file. You may download these advanced tools from the Microsoft web site.

Once you have defined the terms, you need to specify the actions that will take place when the user clicks on the Smart Tag button. In this example, we have defined three actions:

<FL:actions>

<FL:action id="StateLookup"> <FL:caption>View State Information</FL:caption> <FL:url>http://www.americaslibrary.gov/cgi-bin/page.cgi/ _ es?subject={TEXT}</FL:url>

<FL:action id="MoreInfo">

<FL:caption>More State Info</FL:caption> <FL:url>http://www.ipl.org/div/kidspace/stateknow/ _ {TEXT}1.html</FL:url>

</FL:action> <FL:action id="Facts">

<FL:caption>Did You Know...</FL:caption> <FL:url>http://www.ipl.org/div/kidspace/stateknow/ _ {TEXT}2.html</FL:url>

Notice that each action has an action ID, a caption, and the URL that should be activated when the user selects a smart tag menu item. The first action will open the browser, navigate to the americaslibrary.gov web site, and invoke the cgi application named page.cgi located in the cgi-bin folder. Once there, it will run the script named "es," passing to it the name of the term as the subject argument. Note that {TEXT} will be substituted with the term that caused the smart tag to be invoked. The other two actions in this example will navigate to another web address and run appropriate HTML files. Notice that in both examples the name of the HTML file includes the name of the term. Before you define your smart tag actions, you need to investigate which arguments are required to get the information you need from a specific web site.

0 0

Post a comment