Last reviewed: 3/23/2024 12:02:24 PM
<choice>
A <choice> element defines a menu item.
Syntax
<choice accept="accepttype"
dtmf="dtmfsequence"
event="event"
eventexpr="expression"
expr="expression"
fetchaudio="uri"
fetchhint="fetchtype"
fetchtimeout="secondsormilliseconds"
maxage="seconds"
maxstale="seconds"
message="string"
messageexpr="expression"
next="uri" />
Attributes
accept
Override the setting for accept in menu for this particular choice. Default value is exact.
Accept Type | Description |
---|---|
approximate | The text of the choice element defines an approximate recognition phrase. |
exact | The text of the choice element defines the exact phrase to be recognized. |
dtmf
The DTMF sequence for this choice.
event
Specify an event to be thrown instead of specifying a next.
eventexpr
An ECMAScript expression evaluating to the name of the event to be thrown.
expr
Specify an expression to evaluate as a URI to transition to instead of specifying a next.
fetchaudio
The URI of the audio clip to play while the fetch is being done. If not specified, the fetchaudio property is used, and if that property is not set, no audio is played during the fetch. The fetching of the audio clip is governed by the audiofetchhint, audiomaxage, audiomaxstale, and fetchtimeout properties in effect at the time of the fetch. The playing of the audio clip is governed by the fetchaudiodelay, and fetchaudiominimum properties in effect at the time of the fetch. The default value is the fetchaudio property.
fetchhint
Defines when the interpreter context should retrieve content from the server. If not specified, a value derived from the innermost relevant fetchhint property is used. The default value is the documentfetchhint property.
Fetch Type | Description |
---|---|
prefetch | Indicates a file may be downloaded when the page is loaded. |
safe | Indicates a file that should only be downloaded when actually needed. |
fetchtimeout
The interval to wait for the content to be returned before throwing an error.badfetch event. The value is a Time Designation. The default value is the fetchtimeout property.
maxage
Indicates that the document is willing to use content whose age is no greater than the specified time in seconds. The document is not willing to use stale content, unless maxstale is also provided. If not specified, a value derived from the innermost relevant maxage property, if present, is used. The default value is the documentmaxage property.
maxstale
Indicates that the document is willing to use content that has exceeded its expiration time. If maxstale is assigned a value, then the document is willing to accept content that has exceeded its expiration time by no more than the specified number of seconds. If not specified, a value derived from the innermost relevant maxstale property, if present, is used. The default value is the documentmaxstale property.
message
A message string providing additional context about the event being thrown. The message is available as the value of a variable within the scope of the catch element.
messageexpr
An ECMAScript expression evaluating to the message string.
next
The URI of next dialog or document.
Children
Parents
Variables
none
Example
The following example illustrates using example elements.
<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/vxml
http://www.w3.org/TR/voicexml20/vxml.xsd"
version="2.0">s
<meta name="author" content="VoiceXML 2.0"/>
<meta name="maintainer" content="productsupport@chant.net"/>
<var name="hi" expr="'Hello World!'"/>
<menu>
<choice next="http://www.sports.example.com/vxml/start.vxml">
<grammar src="sports.grxml" type="application/srgs+xml"/>
Sports
</choice>
<choice next="http://www.weather.example.com/intro.vxml">
<grammar src="weather.grxml" type="application/srgs+xml"/>
Weather
</choice>
<choice next="http://www.stargazer.example.com/voice/astronews.vxml">
<grammar src="astronews.grxml" type="application/srgs+xml"/>
Stargazer astrophysics
</choice>
</menu>
</vxml>
Supported in: VoiceXML 1.0, VoiceXML 2.0, and VoiceXML 2.1.