Anchors in CMRL

CMRL Version 1.0

1 Introduction

Anchors in CMRL are used to establish links to content. Anchors are similar to anchors on the web: they make it easy to create a way for users to navigate a content hierarchy.

This document describes anchors in CMRL. The document assumes that you have some familiarity with DOTGO and CMRL (obtained, e.g., by reading A Brief Introduction to DOTGO).

2 A Simple Example

Let's start by considering a simple example. Consider the following CMRL fragment under the internet domain name "example":

<match pattern="">
  <message>
    <content>Welcome to example.com<br/>
Reply # for result<br/>
<a query="example circle"/> Circle<br/>
<a query="example square"/> Square<br/>
<a query="example triangle"/> Triangle</content>
  </message>
</match>

<match pattern="circle">
  <message>
    <content>You have selected a circle</content>
  </message>
</match>

<match pattern="square">
  <message>
    <content>You have selected a square</content>
  </message>
</match>

<match pattern="triangle">
  <message>
    <content>You have selected a triangle</content>
  </message>
</match>
Here the query "example circle" produces the response "You have selected a circle," the query "example square" produces the response "You have selected a square," and the query "example triangle" produces the response "You have selected a triangle." The query "example" produces the response
Reply # for result
(1) Circle
(2) Square
(3) Triangle
The query "example" followed immediately (in the very next text message) by the reply "1" produces the response "You have selected a circle." Similarly, the query "example" followed by the reply "2" produces the response "You have selected a square," and the query "example" followed by the reply "3" produces the response "You have selected a triangle."

How does it work? The "null" match contains a <message> tag that contains a <content> tag that contains three <a> tags. The <a> tag is used within a <content> tag. The <a> tag must contain the attribute query and may contain a text string. The system turns the <a> tags within a <content> tag into links, which it enumerates, formats, and displays. If a <content> tag contains an <a> tag, then the reply sent by the user is treated differently than normal; in particular, if the reply matches one of the enumerated links, then the query specified by the corresponding <a> tag is executed as though it were an incoming request. (If the reply sent by the user does not match one of the enumerated links, then it is treated as a normal query.)

3 The <a> and <anchor> Tags

The <a> tag is an abbreviated version of the similar but more general <anchor> tag. Consider the following CMRL fragment under the internet domain name "example":

<match pattern="weather">
  <message>
    <content>Today sunny, H 72<br/>
Reply <anchor>
      <message>
        <content>Today will be sunny and fair with a high of 72 deg F</content>
      <message>
</anchor> for details<br/>
<br/>
Tonight clear, L 47<br/>
Reply <anchor>
      <message>
        <content>Tonight will be clear and cool with a low of 47 deg F</content>
      </message>
</anchor> for details</content>
  </message>
</match>
Here the query "example weather" produces the response
Today sunny, H 72
Reply (1) for details

Tonight clear, L 47
Reply (2) for details
The reply "1" produces the response "Today will be sunny and fair with a high of 72 deg F," whereas the reply "2" produces the response "Tonight will be clear and cool with a low of 47 deg F."

Like the <a> tag, the <anchor> tag is used within a <content> tag, and the system turns the <anchor> tags within a <content> tag into links which it enumerates, formats, and displays. The difference between the <a> tag and the <anchor> tag is that the <a> tag can refer only to a query whereas the <anchor> tag can refer to any CMRL terminating node. Specifically, the <anchor> tag must contain exactly one terminating node (which in this case is the <message> tag), which is resolved to if the reply matches the corresponding enumerated link.

To be clear about the similarity between the <a> tag and the <anchor> tag, let's consider a final example. The following CMRL fragment under the internet domain name "example"

<match pattern="">
  <message>
    <content>He was able to <a query="example elucidate">elucidate</a>
the subject</content>
  </message>
</match>

<match pattern="elucidate">
  <message>
    <content>elucidate -verb<br/>
to make lucid or clear; throw light upon; explain</content>
  </message>
</match>
is equivalent to the following CMRL fragment under the internet domain name "example"
<match pattern="">
  <message>
    <content>He was able to <anchor><query>example elucidate</query>
elucidate</anchor> the subject</content>
  </message>
</match>

<match pattern="elucidate">
  <message>
    <content>elucidate -verb<br/>
to make lucid or clear; throw light upon; explain</content>
  </message>
</match>
In both cases, the query "example" produces the response
He was able to elucidate(1) the subject
and the reply "1" produces the response
elucidate -verb
to make lucid or clear; throw light upon; explain

4 Summary

By establishing links to specific content, anchors make it easy to create a way for users to navigate a content hierarchy. The next step is to try it for yourself.