Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer_guide:voicexml_references:elements:choice [2015/10/13 21:42] (current)
borja created
Line 1: Line 1:
 +====== < choice > ======
  
 +===== Description =====
 +The <​choice>​ element defines a menu item and serves several purposes:
 +  * Specifies a speech grammar fragment and/or a DTMF grammar fragment that determines when that choice has been selected.
 +  * Forms the <​enumerate>​ prompt string with its contents.
 +  * Specifies the URI to go to when the choice is selected.
 +
 +===== Syntax =====
 +<​code>​
 +<choice
 +dtmf="​DTMF sequence"​
 +accept="​exact"​ | "​approximate"​
 +next="​URI"​
 +event="​event"​
 +expr="​ECMAScript_Expression"​
 +fetchaudio="​URI"​
 +fetchhint="​prefetch"​ | "​safe"​
 +fetchtimeout="​time_interval"​
 +maxage="​time_interval"​
 +maxstale="​time_interval">​
 +child elements
 +</​choice>​
 +</​code>​
 +
 +===== Attributes =====
 +
 +|dtmf|This attribute is the DTMF sequence for this choice. This attribute is optional.|
 +|accept|The accept attribute overrides the setting for the accepted attribute in the <​menu>​ element, with either exact or approximate values. ​ This attribute is optional and defaults to exact. * exact – use exact to define the exact phrase to be recognized. * approximate – use approximate to define an approximate recognition phrase. A subset of the words in the phrase expression can be matched. ​ For example, "Hello world" can be matched with "Hello world",​ "​Hello",​ or "​World"​.|
 +|next|The next attribute is the URI of the next dialog or document.|
 +|event|This attribute throws a specified event. ​ Next and expr attributes have precedence over this attribute.|
 +|expr|The expr attribute is an ECMAScript Expression that defines the URI to transition. ​ The next attribute has precedence over this attribute.|
 +|fetchaudio|The fetchaudio attribute is the URI of the audio to play while waiting for the next document to be fetched.|
 +|fetchtimeout|This attribute indicates the time interval to wait for an audio file to be fetched before playing the alternate content. ​ This attribute is optional.|
 +|fetchhint|The fetchhint attribute defines when the audio file should be retrieved. ​ This attribute is optional. * prefetch - the file can be fetched when the document is loaded. * safe - the file is fetched only when needed.|
 +|maxage|This attribute indicates the maximum time in seconds that this document will use this file before fetching another copy.  This attribute is optional.|
 +|maxstale|The maxstale attribute indicates the maximum time in seconds that this document will use the file that exceeded the maxage time.  This attribute is optional.|
 +
 +===== Parents =====
 +<​code>​
 +<​menu>​
 +</​code>​
 +
 +===== Children =====
 +<​code>​
 +<​audio>,​ <​enumerate>,​ <​grammar>,​ <​value>​
 +</​code>​
 +
 +===== Extensions =====
 +<​code>​
 +None.
 +</​code>​
 +
 +===== Limitations/​Restrictions =====
 +<​code>​
 +The dtmf attribute must be specified.
 +</​code>​
 +
 +===== Example Code =====
 +<​code>​
 +<?xml version="​1.0"?>​
 +<vxml version="​2.0"​ xmlns="​http://​www.w3.org/​2001/​vxml">​
 + <​menu>​
 +  <​prompt>​ What do you want for drink, coffee or tea? </​prompt>​
 +  <choice dtmf="​1"​ next="#​getcoffee">​ coffee </​choice>​
 +  <choice dtmf="​2"​ next="#​gettea">​ tea </​choice>​
 +  <​noinput>​ Please say coffee or tea </​noinput>​
 +  <​nomatch>​ Please say coffee or tea </​nomatch>​
 + </​menu>​
 + <​form id="​getcoffee">​
 +  <​block>​
 +   <​prompt>​Ok,​ here's your coffee</​prompt>​
 +  </​block>​
 + </​form>​
 + <​form id="​gettea">​
 +  <​block>​
 +   <​prompt>​Ok,​ here's your tea</​prompt>​
 +  </​block>​
 + </​form>​
 +</​vxml>​
 +</​code>​