
VoxML 1.0 Element Reference
SWITCH Element
SWITCH Element
The SWITCH element is used to define the application behavior dependant on the value of a specified recognition slot. The SWITCH element is used only in conjunction with the CASE element.
The SWITCH element can exist only within the INPUT element, and then only when using the GRAMMAR input type.
Syntax
<SWITCH FIELD="value"> VoxML </SWITCH>
Attributes
Attribute Name | Allowed Values |
FIELDidentifier
Examples
1<INPUT TYPE="GRAMMAR"
2SRC="gram://.Banking/action/amount/fromacct/toacct">
3<SWITCH FIELD="action">
4<CASE VALUE="transfer" NEXT="#transfer" />
5<CASE VALUE="balance" NEXT="#balance" />
6<CASE VALUE="activity">
7<SWITCH FIELD="fromacct">
8<CASE VALUE="checking" NEXT="#chxact" />
9<CASE VALUE="savings" NEXT="#savact" />
10</SWITCH>
11</CASE>
12</SWITCH>
13</INPUT>
This example shows how a SWITCH element might be used to determine the next step to execute in response to a banking request. In this example, the grammar may fill in some or all of the variables “action”, “amount”, “fromacct”, and “toacct”. If the user asks for a transfer or balance action, the next step to execute is the transfer or balance step. If the user asks for a report of account activity, a second SWITCH element determines the next step based on the account type for which a report is being requested (assumed to be available in the “fromacct” variable).
October 1998 | VoxML 1.0 Language Reference 45 |